Skip to content

Commit

Permalink
ok.. avoid using toJSBox too on globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodwine committed Sep 30, 2023
1 parent ea785a0 commit 28803d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions browser_library_test/test/node_js_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'package:test/test.dart';

@TestOn('browser')
void main() {
tearDown(() => globalThis.toJSBox.delete('process'.toJS));
tearDown(() => delete(globalThis, 'process'));

const nonNodeJsProcessTestCases = <String, Map<String, Map<String, String>>>{
'an empty process': {},
Expand All @@ -45,13 +45,13 @@ void main() {
final processJson = entry.value.jsify();

test("returns 'false' when $caseName exists in the 'window'", () {
globalThis.toJSBox['process'.toJS] = processJson;
setProperty(globalThis, 'process', processJson);
expect(isNodeJs, isFalse);
});
}

test("returns 'true' with a fake Node.JS process", () {
globalThis.toJSBox['process'.toJS] = fakeNodeJsProcess.jsify();
setProperty(globalThis, 'process', fakeNodeJsProcess.jsify());
expect(isNodeJs, isTrue);
});
});
Expand All @@ -66,13 +66,13 @@ void main() {
final processJson = entry.value.jsify();

test("returns 'null' when $caseName exists in the 'window'", () {
globalThis.toJSBox['process'.toJS] = processJson;
setProperty(globalThis, 'process', processJson);
expect(process, isNull);
});
}

test("returns a fake process if it fakes being a Node.JS environment", () {
globalThis.toJSBox['process'.toJS] = fakeNodeJsProcess.jsify();
setProperty(globalThis, 'process', fakeNodeJsProcess.jsify());
expect(process.jsify().dartify(), fakeNodeJsProcess);
});
});
Expand Down

0 comments on commit 28803d3

Please sign in to comment.