Files
react-native-devtools-frontend/front_end/models/javascript_metadata/JavaScriptMetadata.test.ts
T
Benedikt Meurer 5cb9f987f7 Disallow equality assertions with boolean, null, and undefined.
Require the more descriptive `assert.isTrue`, `assert.isFalse`,
`assert.isNull`, `assert.isUndefined`, and friends instead, which also
produce a more meaningful error message than the generic
`assert.strictEqual`, `assert.deepEqual`, and friends.

Bug: 386335487
Change-Id: Ic58a07381196c358a43857b53364d74076e9c7e8
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6113833
Reviewed-by: Changhao Han <changhaohan@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
2024-12-30 00:32:53 -08:00

63 lines
2.2 KiB
TypeScript

// 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);
});
});
});