|
11 | 11 |
|
12 | 12 | import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; |
13 | 13 |
|
| 14 | +declare var PerformanceObserverEntryList: unknown; |
| 15 | +declare var EventCounts: unknown; |
| 16 | + |
14 | 17 | describe('setUpDefaultReactNativeEnvironment (globals)', () => { |
15 | | - it('should be exposed as globalThis, global, window and self', () => { |
16 | | - expect(globalThis).toBe(global); |
17 | | - expect(globalThis).toBe(window); |
18 | | - expect(globalThis).toBe(self); |
| 18 | + describe('global object', () => { |
| 19 | + it('should be exposed as globalThis, global, window and self', () => { |
| 20 | + expect(globalThis).toBe(global); |
| 21 | + expect(globalThis).toBe(window); |
| 22 | + expect(globalThis).toBe(self); |
| 23 | + }); |
| 24 | + }); |
| 25 | + |
| 26 | + describe('environment', () => { |
| 27 | + it('should provide process.env.NODE_ENV', () => { |
| 28 | + expect(process.env.NODE_ENV).toBe('development'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should provide the __DEV__ constant', () => { |
| 32 | + expect(__DEV__).toBe(true); |
| 33 | + }); |
19 | 34 | }); |
20 | 35 |
|
21 | | - it('should provide process.env.NODE_ENV', () => { |
22 | | - expect(process.env.NODE_ENV).toBe('development'); |
| 36 | + describe('JavaScript language features', () => { |
| 37 | + it('should provide Promise', () => { |
| 38 | + expect(typeof Promise).toBe('function'); |
| 39 | + }); |
23 | 40 | }); |
24 | 41 |
|
25 | | - it('should provide the __DEV__ constant', () => { |
26 | | - expect(__DEV__).toBe(true); |
| 42 | + describe('Web APIs', () => { |
| 43 | + describe('DOM', () => { |
| 44 | + it('should provide Node', () => { |
| 45 | + expect(typeof Node).toBe('function'); |
| 46 | + }); |
| 47 | + |
| 48 | + it('should provide Document', () => { |
| 49 | + expect(typeof Document).toBe('function'); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should provide CharacterData', () => { |
| 53 | + expect(typeof CharacterData).toBe('function'); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should provide Text', () => { |
| 57 | + expect(typeof Text).toBe('function'); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should provide Element', () => { |
| 61 | + expect(typeof Element).toBe('function'); |
| 62 | + }); |
| 63 | + |
| 64 | + it('should provide HTMLElement', () => { |
| 65 | + expect(typeof HTMLElement).toBe('function'); |
| 66 | + }); |
| 67 | + |
| 68 | + it('should provide HTMLCollection', () => { |
| 69 | + expect(typeof HTMLCollection).toBe('function'); |
| 70 | + }); |
| 71 | + |
| 72 | + it('should provide NodeList', () => { |
| 73 | + expect(typeof NodeList).toBe('function'); |
| 74 | + }); |
| 75 | + }); |
| 76 | + |
| 77 | + describe('Geometry', () => { |
| 78 | + it('should provide DOMRect', () => { |
| 79 | + expect(typeof DOMRect).toBe('function'); |
| 80 | + }); |
| 81 | + |
| 82 | + it('should provide DOMRectReadOnly', () => { |
| 83 | + expect(typeof DOMRectReadOnly).toBe('function'); |
| 84 | + }); |
| 85 | + |
| 86 | + it('should provide DOMRectList', () => { |
| 87 | + expect(typeof DOMRectList).toBe('function'); |
| 88 | + }); |
| 89 | + }); |
| 90 | + |
| 91 | + describe('Events', () => { |
| 92 | + it('should provide Event', () => { |
| 93 | + expect(typeof Event).toBe('function'); |
| 94 | + }); |
| 95 | + |
| 96 | + it('should provide EventTarget', () => { |
| 97 | + expect(typeof EventTarget).toBe('function'); |
| 98 | + }); |
| 99 | + |
| 100 | + it('should provide CustomEvent', () => { |
| 101 | + expect(typeof CustomEvent).toBe('function'); |
| 102 | + }); |
| 103 | + }); |
| 104 | + |
| 105 | + describe('Performance', () => { |
| 106 | + it('should provide performance', () => { |
| 107 | + expect(typeof performance).toBe('object'); |
| 108 | + expect(performance).not.toBeNull(); |
| 109 | + }); |
| 110 | + |
| 111 | + it('should provide Performance', () => { |
| 112 | + expect(typeof Performance).toBe('function'); |
| 113 | + }); |
| 114 | + |
| 115 | + it('should provide PerformanceEntry', () => { |
| 116 | + expect(typeof PerformanceEntry).toBe('function'); |
| 117 | + }); |
| 118 | + |
| 119 | + it('should provide PerformanceMark', () => { |
| 120 | + expect(typeof PerformanceMark).toBe('function'); |
| 121 | + }); |
| 122 | + |
| 123 | + it('should provide PerformanceMeasure', () => { |
| 124 | + expect(typeof PerformanceMeasure).toBe('function'); |
| 125 | + }); |
| 126 | + |
| 127 | + it('should provide PerformanceObserver', () => { |
| 128 | + expect(typeof PerformanceObserver).toBe('function'); |
| 129 | + }); |
| 130 | + |
| 131 | + it('should provide PerformanceObserverEntryList', () => { |
| 132 | + expect(typeof PerformanceObserverEntryList).toBe('function'); |
| 133 | + }); |
| 134 | + |
| 135 | + it('should provide PerformanceEventTiming', () => { |
| 136 | + expect(typeof PerformanceEventTiming).toBe('function'); |
| 137 | + }); |
| 138 | + |
| 139 | + it('should provide PerformanceLongTaskTiming', () => { |
| 140 | + expect(typeof PerformanceLongTaskTiming).toBe('function'); |
| 141 | + }); |
| 142 | + |
| 143 | + it('should provide PerformanceResourceTiming', () => { |
| 144 | + expect(typeof PerformanceResourceTiming).toBe('function'); |
| 145 | + }); |
| 146 | + |
| 147 | + it('should provide EventCounts', () => { |
| 148 | + expect(typeof EventCounts).toBe('function'); |
| 149 | + }); |
| 150 | + |
| 151 | + it('should provide TaskAttributionTiming', () => { |
| 152 | + expect(typeof TaskAttributionTiming).toBe('function'); |
| 153 | + }); |
| 154 | + }); |
| 155 | + |
| 156 | + describe('Timers and microtasks', () => { |
| 157 | + it('should provide setTimeout', () => { |
| 158 | + expect(typeof setTimeout).toBe('function'); |
| 159 | + }); |
| 160 | + |
| 161 | + it('should provide clearTimeout', () => { |
| 162 | + expect(typeof clearTimeout).toBe('function'); |
| 163 | + }); |
| 164 | + |
| 165 | + it('should provide setInterval', () => { |
| 166 | + expect(typeof setInterval).toBe('function'); |
| 167 | + }); |
| 168 | + |
| 169 | + it('should provide clearInterval', () => { |
| 170 | + expect(typeof clearInterval).toBe('function'); |
| 171 | + }); |
| 172 | + |
| 173 | + it('should provide setImmediate', () => { |
| 174 | + expect(typeof setImmediate).toBe('function'); |
| 175 | + }); |
| 176 | + |
| 177 | + it('should provide clearImmediate', () => { |
| 178 | + expect(typeof clearImmediate).toBe('function'); |
| 179 | + }); |
| 180 | + |
| 181 | + it('should provide requestAnimationFrame', () => { |
| 182 | + expect(typeof requestAnimationFrame).toBe('function'); |
| 183 | + }); |
| 184 | + |
| 185 | + it('should provide cancelAnimationFrame', () => { |
| 186 | + expect(typeof cancelAnimationFrame).toBe('function'); |
| 187 | + }); |
| 188 | + |
| 189 | + it('should provide requestIdleCallback', () => { |
| 190 | + expect(typeof requestIdleCallback).toBe('function'); |
| 191 | + }); |
| 192 | + |
| 193 | + it('should provide cancelIdleCallback', () => { |
| 194 | + expect(typeof cancelIdleCallback).toBe('function'); |
| 195 | + }); |
| 196 | + |
| 197 | + it('should provide queueMicrotask', () => { |
| 198 | + expect(typeof queueMicrotask).toBe('function'); |
| 199 | + }); |
| 200 | + }); |
| 201 | + |
| 202 | + describe('Networking', () => { |
| 203 | + it('should provide XMLHttpRequest', () => { |
| 204 | + expect(typeof XMLHttpRequest).toBe('function'); |
| 205 | + }); |
| 206 | + |
| 207 | + it('should provide FormData', () => { |
| 208 | + expect(typeof FormData).toBe('function'); |
| 209 | + }); |
| 210 | + |
| 211 | + it('should provide fetch', () => { |
| 212 | + expect(typeof fetch).toBe('function'); |
| 213 | + }); |
| 214 | + |
| 215 | + it('should provide Headers', () => { |
| 216 | + expect(typeof Headers).toBe('function'); |
| 217 | + }); |
| 218 | + |
| 219 | + it('should provide Request', () => { |
| 220 | + expect(typeof Request).toBe('function'); |
| 221 | + }); |
| 222 | + |
| 223 | + it('should provide Response', () => { |
| 224 | + expect(typeof Response).toBe('function'); |
| 225 | + }); |
| 226 | + |
| 227 | + it('should provide WebSocket', () => { |
| 228 | + expect(typeof WebSocket).toBe('function'); |
| 229 | + }); |
| 230 | + |
| 231 | + it('should provide AbortController', () => { |
| 232 | + expect(typeof AbortController).toBe('function'); |
| 233 | + }); |
| 234 | + |
| 235 | + it('should provide AbortSignal', () => { |
| 236 | + expect(typeof AbortSignal).toBe('function'); |
| 237 | + }); |
| 238 | + |
| 239 | + it('should provide URL', () => { |
| 240 | + expect(typeof URL).toBe('function'); |
| 241 | + }); |
| 242 | + |
| 243 | + it('should provide URLSearchParams', () => { |
| 244 | + expect(typeof URLSearchParams).toBe('function'); |
| 245 | + }); |
| 246 | + }); |
| 247 | + |
| 248 | + describe('File', () => { |
| 249 | + it('should provide Blob', () => { |
| 250 | + expect(typeof Blob).toBe('function'); |
| 251 | + }); |
| 252 | + |
| 253 | + it('should provide File', () => { |
| 254 | + expect(typeof File).toBe('function'); |
| 255 | + }); |
| 256 | + |
| 257 | + it('should provide FileReader', () => { |
| 258 | + // Note: accessing `FileReader` directly triggers a lazy require that |
| 259 | + // depends on a native module not available in the Fantom test |
| 260 | + // environment. Verify the global property is registered without |
| 261 | + // triggering the lazy getter. |
| 262 | + expect('FileReader' in globalThis).toBe(true); |
| 263 | + }); |
| 264 | + }); |
| 265 | + |
| 266 | + describe('Other', () => { |
| 267 | + it('should provide alert', () => { |
| 268 | + expect(typeof alert).toBe('function'); |
| 269 | + }); |
| 270 | + |
| 271 | + it('should provide navigator', () => { |
| 272 | + expect(typeof navigator).toBe('object'); |
| 273 | + expect(navigator).not.toBeNull(); |
| 274 | + }); |
| 275 | + }); |
27 | 276 | }); |
28 | 277 | }); |
0 commit comments