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
+17
View File
@@ -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)
})
})
})