forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquery.test.ts
45 lines (36 loc) · 1.34 KB
/
query.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
44
45
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */
import assert from 'node:assert/strict';
import query from './query.js';
describe('query()', () => {
describe('should throw on non-existent features', () => {
assert.throws(() => query('nonExistentNameSpace'), ReferenceError);
assert.throws(() => query('api.NonExistentFeature'), ReferenceError);
assert.throws(
() => query('api.NonExistentFeature.subFeature'),
ReferenceError,
);
assert.throws(() => query('foo.'), ReferenceError);
});
it('should return the expected point in the tree (namespace)', () => {
const obj = query('css');
assert.ok(!('__compat' in obj));
assert.ok('properties' in obj);
assert.ok('at-rules' in obj);
});
it('should return the expected point in the tree (feature)', () => {
const obj = query('api.HTMLAnchorElement.href');
assert.ok('support' in obj.__compat);
assert.ok('status' in obj.__compat);
assert.equal(
'https://developer.mozilla.org/docs/Web/API/HTMLAnchorElement/href',
obj.__compat.mdn_url,
);
});
it('should return the expected point in the tree (feature with children)', () => {
const obj = query('api.HTMLAnchorElement');
assert.ok('__compat' in obj);
assert.ok('charset' in obj);
assert.ok('href' in obj);
});
});