fix: stable sort for undefined keys, fixes #191

This commit is contained in:
harttle
2020-03-05 02:04:58 +08:00
parent 61dac49b04
commit f57156bccd
5 changed files with 48 additions and 13 deletions
+13
View File
@@ -89,6 +89,19 @@ describe('filters/math', function () {
const html = await l.parseAndRender(src, { students })
expect(html).to.equal('bob alice carol')
})
it('should be stable when it comes to undefined props', async () => {
const src = '{{ students | sort_natural: "age" | map: "name" | join }}'
const students = [
{ name: 'bob' },
{ name: 'alice', age: 2 },
{ name: 'amber' },
{ name: 'watson' },
{ name: 'michael' },
{ name: 'charlie' }
]
const html = await l.parseAndRender(src, { students })
expect(html).to.equal('alice bob amber watson michael charlie')
})
it('should tolerate undefined props', async () => {
const src = '{{ students | sort_natural: "age" | map: "name" | join }}'
const students = [