2016-12-12 12:31:49 +00:00
|
|
|
/* global expect, describe, test */
|
|
|
|
|
|
|
|
'use strict'
|
|
|
|
|
2016-11-15 08:24:20 +00:00
|
|
|
import shallowEquals from '../../lib/shallow-equals'
|
|
|
|
|
2016-12-12 12:31:49 +00:00
|
|
|
describe('shallow-equals', () => {
|
|
|
|
test('returns true if all key/value pairs match', () => {
|
|
|
|
expect(shallowEquals({
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: 99
|
|
|
|
}, {
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: 99
|
|
|
|
})).toBeTruthy()
|
|
|
|
})
|
2016-11-15 08:24:20 +00:00
|
|
|
|
2016-12-12 12:31:49 +00:00
|
|
|
test('returns false if any key/value pair is different', () => {
|
|
|
|
expect(shallowEquals({
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: 99
|
|
|
|
}, {
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: 99,
|
|
|
|
d: 33
|
|
|
|
})).toBeFalsy()
|
|
|
|
})
|
2016-11-15 08:24:20 +00:00
|
|
|
|
2016-12-12 12:31:49 +00:00
|
|
|
test('returns false if nested objects are contained', () => {
|
|
|
|
expect(shallowEquals({
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: {}
|
|
|
|
}, {
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: {}
|
|
|
|
})).toBeFalsy()
|
|
|
|
})
|
2016-11-15 08:24:20 +00:00
|
|
|
})
|