forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraverse.test.ts
43 lines (36 loc) · 1.05 KB
/
traverse.test.ts
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
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */
import assert from 'node:assert/strict';
import { BrowserName } from '../types/types.js';
import { iterateFeatures } from './traverse.js';
describe('iterateFeatures', () => {
it('should yield correct identifiers for given object', () => {
const obj = {
feature1: {
__compat: {
support: {
chrome: { version_added: '1.0' },
firefox: { version_added: '1.5' },
},
},
},
feature2: {
__compat: {
support: {
chrome: { version_added: '2.0' },
firefox: { version_added: null },
},
},
},
};
const browsers: BrowserName[] = ['chrome', 'firefox'];
const values = ['1.0', 'null'];
const depth = 2;
const tag = '';
const identifier = '';
const result = Array.from(
iterateFeatures(obj, browsers, values, depth, tag, identifier),
);
assert.deepEqual(result, ['feature1', 'feature2']);
});
});