mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
This removes the pattern
```js
const {assert} = chai;
```
from our unit test suite, which is fundamentally incompatible with
TypeScript `asserts`, which we intend to put onto Chai assert
functions. And this is also unnecessary, since `karma-chai` (and
also `karma-chai-sinon`) already provide `assert` as a global (with
the proper types).
Bug: 333520272
Change-Id: Id5dfd65903b5b116414709782c7923fc5523e480
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5439575
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Philip Pfaffe <pfaffe@chromium.org>
75 lines
2.3 KiB
TypeScript
75 lines
2.3 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 Host from '../host/host.js';
|
|
|
|
import * as ProtocolClient from './protocol_client.js';
|
|
|
|
describe('NodeURL', () => {
|
|
describe('platform detection for paths', () => {
|
|
it('works correctly on windows', () => {
|
|
const isWindows = true;
|
|
assert.isTrue(ProtocolClient.NodeURL.NodeURL.isPlatformPath('c:\\prog\\foobar.js', isWindows));
|
|
assert.isFalse(ProtocolClient.NodeURL.NodeURL.isPlatformPath('/usr/local/foobar.js', isWindows));
|
|
});
|
|
|
|
it('works correctly on linux', () => {
|
|
const isWindows = false;
|
|
assert.isFalse(ProtocolClient.NodeURL.NodeURL.isPlatformPath('c:\\prog\\foobar.js', isWindows));
|
|
assert.isTrue(ProtocolClient.NodeURL.NodeURL.isPlatformPath('/usr/local/foobar.js', isWindows));
|
|
});
|
|
});
|
|
|
|
describe('patch', () => {
|
|
const url = Host.Platform.isWin() ? 'C:\\prog\\foobar.js' : '/usr/local/home/prog/foobar.js';
|
|
const validPatchedUrl =
|
|
Host.Platform.isWin() ? 'file:///C:/prog/foobar.js' : 'file:///usr/local/home/prog/foobar.js';
|
|
|
|
it('does patch url fields', () => {
|
|
const object = {url, result: null};
|
|
|
|
ProtocolClient.NodeURL.NodeURL.patch(object);
|
|
|
|
assert.strictEqual(object.url, validPatchedUrl);
|
|
});
|
|
|
|
it('does not patch the url of the result', () => {
|
|
const object = {
|
|
url: '',
|
|
result: {
|
|
result: {
|
|
value: {url},
|
|
},
|
|
},
|
|
};
|
|
|
|
ProtocolClient.NodeURL.NodeURL.patch(object);
|
|
|
|
assert.strictEqual(object.result.result.value.url, url);
|
|
});
|
|
|
|
it('does patch all urls in an example protocol message', () => {
|
|
const object = {
|
|
exceptionDetails: {
|
|
url,
|
|
stackTrace: {
|
|
callFrames: [{
|
|
columnNumber: 0,
|
|
functionName: '',
|
|
lineNumber: 0,
|
|
scriptId: '0',
|
|
url,
|
|
}],
|
|
},
|
|
},
|
|
};
|
|
|
|
ProtocolClient.NodeURL.NodeURL.patch(object as unknown as {url: string});
|
|
|
|
assert.strictEqual(object.exceptionDetails.url, validPatchedUrl);
|
|
assert.strictEqual(object.exceptionDetails.stackTrace.callFrames[0].url, validPatchedUrl);
|
|
});
|
|
});
|
|
});
|