Support string templating for key-level attributes

This commit is contained in:
Bán Dénes 2022-01-22 23:13:18 +01:00
parent 6225013828
commit 2b98b502d6
10 changed files with 459 additions and 47 deletions

View file

@ -22,6 +22,19 @@ describe('Utils', function() {
should.equal(u.deep(obj, 'non.existent.key'), undefined)
})
it('template', function() {
u.template('arst').should.equal('arst')
u.template('{arst}}').should.equal('{arst}}')
u.template('{{arst}}').should.equal('')
u.template('{{arst}}', {arst: 'neio'}).should.equal('neio')
u.template('{{a}}_{{b}}', {a: 'c', b: 'd'}).should.equal('c_d')
u.template(
'{{longlonglong}}_{{short}}',
{longlonglong: 'long', short: 'shortshortshort'}
).should.equal('long_shortshortshort')
u.template('{{a.b.c}}', {a: {b: {c: 'deep'}}}).should.equal('deep')
})
it('eq', function() {
// basic point usage
u.eq([1, 2], [1, 2]).should.equal(true)