-
-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ improvement(named): using default use nmae when value is missing
- Loading branch information
Showing
2 changed files
with
30 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,18 +8,31 @@ const format = Format(Vue) | |
describe('format', () => { | ||
describe('argument', () => { | ||
context('Object', () => { | ||
it('should be replace with object value', () => { | ||
const template = 'name: {name}, email: {email}' | ||
assert.equal(format(template, { | ||
name: 'kazupon', email: '[email protected]' | ||
}), 'name: kazupon, email: [email protected]') | ||
context('default delimiter', () => { | ||
it('should be replace with object value', () => { | ||
const template = 'name: {name}, email: {email}' | ||
assert.equal(format(template, { | ||
name: 'kazupon', email: '[email protected]' | ||
}), 'name: kazupon, email: [email protected]') | ||
}) | ||
}) | ||
|
||
it('should be replace with object value', () => { | ||
const template = 'name: %{name}, email: %{email}' | ||
assert.equal(format(template, { | ||
name: 'kazupon', email: '[email protected]' | ||
}), 'name: kazupon, email: [email protected]') | ||
context('RoR delimiter', () => { | ||
it('should be replace with object value', () => { | ||
const template = 'name: %{name}, email: %{email}' | ||
assert.equal(format(template, { | ||
name: 'kazupon', email: '[email protected]' | ||
}), 'name: kazupon, email: [email protected]') | ||
}) | ||
}) | ||
|
||
context('missing', () => { | ||
it('should be replace with as is', () => { | ||
const template = 'name: {name}, email: {email}' | ||
assert.equal(format(template, { | ||
name: 'kazupon' | ||
}), 'name: kazupon, email: {email}') | ||
}) | ||
}) | ||
}) | ||
|
||
|
@@ -36,21 +49,21 @@ describe('format', () => { | |
context('null', () => { | ||
it('should be replace with empty', () => { | ||
const template = 'name: {0}, email: {1}' | ||
assert.equal(format(template, null), 'name: , email: ') | ||
assert.equal(format(template, null), 'name: {0}, email: {1}') | ||
}) | ||
}) | ||
|
||
context('undefined', () => { | ||
it('should be replace with empty', () => { | ||
const template = 'name: {0}, email: {1}' | ||
assert.equal(format(template, undefined), 'name: , email: ') | ||
assert.equal(format(template, undefined), 'name: {0}, email: {1}') | ||
}) | ||
}) | ||
|
||
context('not specify', () => { | ||
it('should be replace with empty', () => { | ||
const template = 'name: {0}, email: {1}' | ||
assert.equal(format(template), 'name: , email: ') | ||
assert.equal(format(template), 'name: {0}, email: {1}') | ||
}) | ||
}) | ||
}) | ||
|