-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
31 lines (28 loc) · 694 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import equalByKeys from './'
it('compares objects equality only for the given keys', () => {
const a = {
foo: 'you',
bar: 'today',
baz: 'meadow',
}
const b = {
foo: 'you',
bar: 'tomorrow',
baz: 'meadow',
}
expect(equalByKeys(a, b, 'foo', 'baz')).toBe(true)
b.foo = 'different'
expect(equalByKeys(a, b, 'foo', 'baz')).toBe(false)
})
it('returns true when no keys are passed', () => {
const a = {}
const b = { foo: 'bar' }
expect(equalByKeys(a, b)).toBe(true)
})
it('returns false when one of the objects is missing a key being compared on', () => {
const a = {
foo: 'bar',
}
const b = {}
expect(equalByKeys(a, b, 'foo')).toBe(false)
})