-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
51 lines (35 loc) · 1.17 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const chai = require('chai');
const expect = chai.expect;
const missingDeepKeys = require('./index');
describe('missing deep keys', function() {
it('should return empty array for equal objects', function() {
const o1 = {a: 1};
const o2 = {a: 1};
const result = missingDeepKeys(o1, o2);
expect(result).to.deep.equal([]);
});
it('should return array of missing first-level keys', function() {
const o1 = {a: 1};
const o2 = {};
const result = missingDeepKeys(o1, o2);
expect(result).to.deep.equal(['a']);
});
it('should return array of missing deep-level keys', function() {
const o1 = {a: {b: 2}};
const o2 = {};
const result = missingDeepKeys(o1, o2);
expect(result).to.deep.equal(['a.b']);
});
it('should return array of missing intermediate keys', function() {
const o1 = {a: {b: 2}};
const o2 = {};
const result = missingDeepKeys(o1, o2, true);
expect(result).to.deep.equal(['a', 'a.b']);
});
it('should return empty array for non-object arguments', function() {
const o1 = '';
const o2 = undefined;
const result = missingDeepKeys(o1, o2);
expect(result).to.deep.equal([]);
});
});