mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: stable sort for undefined keys, fixes #191
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -108,4 +108,21 @@ describe('util/underscore', function () {
|
||||
expect(_.changeCase('FOOA')).to.equal('fooa')
|
||||
})
|
||||
})
|
||||
describe('.caseInsensitiveCompare()', function () {
|
||||
it('should "foo" > "bar"', () => {
|
||||
expect(_.caseInsensitiveCompare('foo', 'bar')).to.equal(1)
|
||||
})
|
||||
it('should "foo" < null', () => {
|
||||
expect(_.caseInsensitiveCompare('foo', null)).to.equal(-1)
|
||||
})
|
||||
it('should null > "foo"', () => {
|
||||
expect(_.caseInsensitiveCompare(null, 'foo')).to.equal(1)
|
||||
})
|
||||
it('should -1 < 0', () => {
|
||||
expect(_.caseInsensitiveCompare(-1, 0)).to.equal(-1)
|
||||
})
|
||||
it('should 1 > 0', () => {
|
||||
expect(_.caseInsensitiveCompare(1, 0)).to.equal(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user