fix: reading .first, .last of Array, closes #175

This commit is contained in:
harttle
2019-11-16 01:14:09 +08:00
parent ef289039fb
commit f82da11f5a
2 changed files with 30 additions and 2 deletions
+16
View File
@@ -11,6 +11,10 @@ describe('Context', function () {
foo: 'zoo',
one: 1,
zoo: { size: 4 },
obj: {
first: 'f',
last: 'l'
},
bar: {
zoo: 'coo',
'Mr.Smith': 'John',
@@ -124,6 +128,18 @@ describe('Context', function () {
it('should return undefined if do not have size and length', async function () {
expect(ctx.get('one.size')).to.equal(undefined)
})
it('should read .first of array', async function () {
expect(ctx.get('bar.arr.first')).to.equal('a')
})
it('should read .first of object', async function () {
expect(ctx.get('obj.first')).to.equal('f')
})
it('should read .last of array', async function () {
expect(ctx.get('bar.arr.last')).to.equal('b')
})
it('should read .last of object', async function () {
expect(ctx.get('obj.last')).to.equal('l')
})
})
describe('strictVariables', async function () {
let ctx: Context