File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ export class MockWindow {
131131 return dispatchEvent ( this , ev ) ;
132132 }
133133
134+ get JSON ( ) {
135+ return JSON ;
136+ }
137+
134138 get Event ( ) {
135139 const evClass = eventClassMap . get ( this ) ;
136140 if ( evClass != null ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ describe('globals', () => {
99 } )
1010 class CmpA { }
1111
12- it ( 'should mock json fetch, no input ' , async ( ) => {
12+ it ( 'should resolve raf and setTimeout ' , async ( ) => {
1313 const page = await newSpecPage ( {
1414 components : [ CmpA ] ,
1515 html : `<cmp-a></cmp-a>` ,
@@ -28,6 +28,11 @@ describe('globals', () => {
2828 } ) ;
2929 } ) ;
3030
31+ it ( 'allows access to window.JSON' , async ( ) => {
32+ expect ( JSON . stringify ( [ 0 ] ) ) . toEqual ( '[0]' ) ;
33+ expect ( ( window as any ) . JSON . stringify ( [ 0 ] ) ) . toEqual ( '[0]' ) ;
34+ } ) ;
35+
3136 it ( 'allows access to the Element prototype' , async ( ) => {
3237 @Component ( { tag : 'cmp-el' } )
3338 class CmpEl {
@@ -44,8 +49,10 @@ describe('globals', () => {
4449 html : `<cmp-el></cmp-el>`
4550 } ) ;
4651
47- expect ( page . root ) . toEqualHtml ( `
48- <cmp-el></cmp-el>
49- ` ) ;
52+ expect ( page . rootInstance . proto ) . toBe ( Element . prototype ) ;
53+ expect ( page . rootInstance . proto ) . toBe ( ( page . win as any ) . Element . prototype ) ;
54+ expect ( page . rootInstance . proto ) . toBe ( ( window as any ) . Element . prototype ) ;
55+ expect ( page . rootInstance . proto ) . toBe ( ( global as any ) . Element . prototype ) ;
56+ expect ( page . rootInstance . proto ) . toBeTruthy ( ) ;
5057 } ) ;
5158} ) ;
You can’t perform that action at this time.
0 commit comments