Skip to content

Commit

Permalink
chore: text.
Browse files Browse the repository at this point in the history
  • Loading branch information
radiorz committed Nov 4, 2024
1 parent dcf17b1 commit 3080173
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/utils/lib/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@ import { it, expect } from 'vitest';
import { replaceParams } from './text';

it('replaceParams', () => {
// 一个变量
expect(replaceParams('{app}', { app: 'hahah' })).toBe('hahah');
// 两个变量
expect(replaceParams(`{app}/{org}`, { app: 'hahah', org: 'nnn' })).toBe('hahah/nnn');
// 一个变量但写两次
expect(replaceParams(`{org}/{org}`, { org: 'nnn' })).toBe('nnn/nnn');
// 变量没值 keepMatch=false
expect(replaceParams(`{org}`, {})).toBe('');
expect(replaceParams(`{org}`, { org: null })).toBe('');

// 变量没值 keepMatch=true
expect(replaceParams(`{org}`, {}, { keepMatch: true })).toBe('{org}');
});

0 comments on commit 3080173

Please sign in to comment.