forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathJavaScriptMetadata.test.ts
More file actions
62 lines (50 loc) · 2.25 KB
/
Copy pathJavaScriptMetadata.test.ts
File metadata and controls
62 lines (50 loc) · 2.25 KB
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
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as JavascriptMetadata from './javascript_metadata.js';
describe('JavaScriptMetadata', () => {
let metadata: JavascriptMetadata.JavaScriptMetadata.JavaScriptMetadataImpl;
before(() => {
metadata = new JavascriptMetadata.JavaScriptMetadata.JavaScriptMetadataImpl();
});
it('retrieves native signature by name', () => {
const signatures = metadata.signaturesForNativeFunction('webkitRequestFullScreen');
assert.deepEqual(signatures, [['?options']]);
});
it('does not retrieve native signatures that are bound to an instance', () => {
const signatures = metadata.signaturesForNativeFunction('find');
assert.isNull(signatures);
});
describe('with static methods', () => {
it('retrieves by name and class', () => {
const signatures = metadata.signaturesForStaticMethod('from', 'Array');
assert.deepEqual(signatures, [['iterable', '?mapfn', '?thisArg'], ['arrayLike', '?mapfn', '?thisArg']]);
});
it('does not retrieve methods that are bound to an instance', () => {
const signatures = metadata.signaturesForStaticMethod('includes', 'Array');
assert.isNull(signatures);
});
it('handles a non-existing class', () => {
const signatures = metadata.signaturesForStaticMethod('includes', 'bogus');
assert.isNull(signatures);
});
});
describe('with instance methods', () => {
it('retrieves by name and class', () => {
const signatures = metadata.signaturesForInstanceMethod('assign', 'HTMLSlotElement');
assert.deepEqual(signatures, [['...nodes']]);
});
it('does not retrieve methods that are unbound', () => {
const signatures = metadata.signaturesForInstanceMethod('webkitRequestFullScreen', 'window');
assert.isNull(signatures);
});
it('does not retrieve static methods', () => {
const signatures = metadata.signaturesForInstanceMethod('from', 'Array');
assert.isNull(signatures);
});
it('handles a non-existing class', () => {
const signatures = metadata.signaturesForInstanceMethod('from', 'Sheep');
assert.isNull(signatures);
});
});
});