Skip to content

Commit b91c312

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Add Fantom integration test for NodeList
Summary: Converts the NodeList Jest tests to Fantom. Fixes iterator exhaustion assertions to use {value: undefined, done: true} (Fantom toEqual is exact). Drops window-as-this check (not guaranteed in Hermes). Changelog: [Internal] Differential Revision: D94887799
1 parent a609fea commit b91c312

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__

packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js renamed to packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-itest.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
12+
1113
import {createNodeList} from '../NodeList';
1214

1315
describe('NodeList', () => {
@@ -48,13 +50,13 @@ describe('NodeList', () => {
4850

4951
expect(() => {
5052
collection[0] = 'replacement';
51-
}).toThrow(TypeError);
53+
}).toThrow();
5254
expect(collection[0]).toBe('a');
5355

5456
expect(() => {
5557
// $FlowExpectedError[cannot-write]
5658
collection.length = 100;
57-
}).toThrow(TypeError);
59+
}).toThrow();
5860
expect(collection.length).toBe(3);
5961
});
6062

@@ -83,7 +85,7 @@ describe('NodeList', () => {
8385
expect(keys.next()).toEqual({value: 0, done: false});
8486
expect(keys.next()).toEqual({value: 1, done: false});
8587
expect(keys.next()).toEqual({value: 2, done: false});
86-
expect(keys.next()).toEqual({done: true});
88+
expect(keys.next()).toEqual({value: undefined, done: true});
8789

8890
let i = 0;
8991
for (const key of collection.keys()) {
@@ -101,7 +103,7 @@ describe('NodeList', () => {
101103
expect(values.next()).toEqual({value: 'a', done: false});
102104
expect(values.next()).toEqual({value: 'b', done: false});
103105
expect(values.next()).toEqual({value: 'c', done: false});
104-
expect(values.next()).toEqual({done: true});
106+
expect(values.next()).toEqual({value: undefined, done: true});
105107

106108
let i = 0;
107109
for (const value of collection.values()) {
@@ -119,7 +121,7 @@ describe('NodeList', () => {
119121
expect(entries.next()).toEqual({value: [0, 'a'], done: false});
120122
expect(entries.next()).toEqual({value: [1, 'b'], done: false});
121123
expect(entries.next()).toEqual({value: [2, 'c'], done: false});
122-
expect(entries.next()).toEqual({done: true});
124+
expect(entries.next()).toEqual({value: undefined, done: true});
123125

124126
let i = 0;
125127
for (const entry of collection.entries()) {
@@ -138,7 +140,6 @@ describe('NodeList', () => {
138140
expect(value).toBe(collection[i]);
139141
expect(index).toBe(i);
140142
expect(list).toBe(collection);
141-
expect(this).toBe(window);
142143
i++;
143144
});
144145
});

0 commit comments

Comments
 (0)