-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support template literals to exclude specific pattern
- Loading branch information
Showing
7 changed files
with
873 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { replaceKeywordForObjectParams } from '../../src/utils'; | ||
|
||
describe('replace keyword for object params', () => { | ||
const template = 'Hello :name {{ name }} ${{ name }}'; | ||
|
||
test('replace param with : as prefix', () => { | ||
expect( | ||
replaceKeywordForObjectParams( | ||
template, | ||
{ | ||
name: 'test', | ||
}, | ||
{}, | ||
), | ||
).toEqual('Hello test {{ name }} ${{ name }}'); | ||
}); | ||
|
||
test('replace param with pattern', () => { | ||
expect( | ||
replaceKeywordForObjectParams( | ||
template, | ||
{ | ||
name: 'test', | ||
}, | ||
{ | ||
pattern: '{{ _ }}', | ||
specElement: '_', | ||
}, | ||
), | ||
).toEqual('Hello :name test $test'); | ||
}); | ||
|
||
test('replace param with pattern and exclude pattern has template litterals as prefix', () => { | ||
expect( | ||
replaceKeywordForObjectParams( | ||
template, | ||
{ | ||
name: 'test', | ||
}, | ||
{ | ||
pattern: '{{ _ }}', | ||
specElement: '_', | ||
templateLiterals: '$', | ||
}, | ||
), | ||
).toEqual('Hello :name test {{ name }}'); | ||
|
||
const otherTemplate = 'Hello :name ${{ name }} $${{ name }}'; | ||
|
||
expect( | ||
replaceKeywordForObjectParams( | ||
otherTemplate, | ||
{ | ||
name: 'test', | ||
}, | ||
{ | ||
pattern: '${{ _ }}', | ||
specElement: '_', | ||
templateLiterals: '$', | ||
}, | ||
), | ||
).toEqual('Hello :name test ${{ name }}'); | ||
}); | ||
}); |
Oops, something went wrong.