11"use strict" ;
22
3+ const realGlobal = require ( "./real-global" ) ;
4+
35this . topLevelAssignment = "assigned" ;
46
57Object . defineProperty ( this , "topLevelDefined" , { value : "defined" } ) ;
@@ -13,31 +15,31 @@ function receiver() {
1315module . exports . marker = "exports" ;
1416
1517it ( "should make the top level this the global object" , ( ) => {
16- expect ( this ) . toBe ( globalThis ) ;
18+ expect ( this ) . toBe ( realGlobal ) ;
1719 expect ( this ) . not . toBe ( module . exports ) ;
1820} ) ;
1921
2022it ( "should assign to the global object" , ( ) => {
21- expect ( globalThis . topLevelAssignment ) . toBe ( "assigned" ) ;
23+ expect ( realGlobal . topLevelAssignment ) . toBe ( "assigned" ) ;
2224 expect ( module . exports . topLevelAssignment ) . toBe ( undefined ) ;
2325} ) ;
2426
2527it ( "should define a property on the global object" , ( ) => {
26- expect ( globalThis . topLevelDefined ) . toBe ( "defined" ) ;
28+ expect ( realGlobal . topLevelDefined ) . toBe ( "defined" ) ;
2729 expect ( module . exports . topLevelDefined ) . toBe ( undefined ) ;
2830} ) ;
2931
3032it ( "should read the global object through a top level arrow function" , ( ) => {
31- expect ( fromArrow ) . toBe ( globalThis ) ;
33+ expect ( fromArrow ) . toBe ( realGlobal ) ;
3234} ) ;
3335
3436it ( "should leave the this of a function alone" , ( ) => {
3537 expect ( receiver . call ( "context" ) ) . toBe ( "context" ) ;
3638} ) ;
3739
3840it ( "should keep top level declarations in the module scope" , ( ) => {
39- expect ( globalThis [ " receiver" ] ) . toBe ( undefined ) ;
40- expect ( globalThis [ " fromArrow" ] ) . toBe ( undefined ) ;
41+ expect ( realGlobal . receiver ) . toBe ( undefined ) ;
42+ expect ( realGlobal . fromArrow ) . toBe ( undefined ) ;
4143} ) ;
4244
4345it ( "should keep exporting through module.exports" , ( ) => {
0 commit comments