Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: suite for expected global object behaviour
- Loading branch information
Showing
3 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
import React from 'react'; | ||
import { PropsPrinter } from '../../../__utils__'; | ||
|
||
const window_moduleLoadTime = typeof window !== 'undefined'; | ||
const document_moduleLoadTime = typeof document !== 'undefined'; | ||
const isWeb_moduleLoadTime = window_moduleLoadTime && document_moduleLoadTime; | ||
|
||
export default function gip(props) { | ||
const window_componentScope = typeof window !== 'undefined'; | ||
const document_componentScope = typeof document !== 'undefined'; | ||
const isWeb_componentScope = window_componentScope && document_componentScope; | ||
|
||
return ( | ||
<> | ||
<h2>Page</h2> | ||
<PropsPrinter | ||
props={{ | ||
...props, | ||
window_componentScope: typeof window !== 'undefined', | ||
document_componentScope: typeof document !== 'undefined', | ||
/* Should be hydrated "client" side where browser is defined */ | ||
window_componentScope, | ||
document_componentScope, | ||
isWeb_componentScope, | ||
window_componentScope_moduleLoadTime: window_moduleLoadTime, | ||
document_componentScope_moduleLoadTime: document_moduleLoadTime, | ||
isWeb_componentScope_moduleLoadTime: isWeb_moduleLoadTime, | ||
}} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
gip.getInitialProps = async () => { | ||
const window_dataFetchingScope = typeof window !== 'undefined'; | ||
const document_dataFetchingScope = typeof document !== 'undefined'; | ||
const isWeb_dataFetchingScope = | ||
window_dataFetchingScope && document_dataFetchingScope; | ||
|
||
return { | ||
window_moduleLoadTime, | ||
document_moduleLoadTime, | ||
window_dataFetchingScope: typeof window !== 'undefined', | ||
document_dataFetchingScope: typeof document !== 'undefined', | ||
isWeb_moduleLoadTime, | ||
window_dataFetchingScope, | ||
document_dataFetchingScope, | ||
isWeb_dataFetchingScope, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,48 @@ | ||
import React from 'react'; | ||
import { PropsPrinter } from '../../../__utils__'; | ||
|
||
const window_moduleLoadTime = typeof window !== 'undefined'; | ||
const document_moduleLoadTime = typeof document !== 'undefined'; | ||
const isWeb_moduleLoadTime = window_moduleLoadTime && document_moduleLoadTime; | ||
|
||
export default function ssr(props) { | ||
const window_componentScope = typeof window !== 'undefined'; | ||
const document_componentScope = typeof document !== 'undefined'; | ||
const isWeb_componentScope = window_componentScope && document_componentScope; | ||
|
||
return ( | ||
<> | ||
<h2>Page</h2> | ||
<PropsPrinter | ||
props={{ | ||
...props, | ||
window_componentScope: typeof window !== 'undefined', | ||
document_componentScope: typeof document !== 'undefined', | ||
/* Should be hydrated "client" side where browser is defined */ | ||
window_componentScope, | ||
document_componentScope, | ||
isWeb_componentScope, | ||
window_componentScope_moduleLoadTime: window_moduleLoadTime, | ||
document_componentScope_moduleLoadTime: document_moduleLoadTime, | ||
isWeb_componentScope_moduleLoadTime: isWeb_moduleLoadTime, | ||
}} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
export async function getServerSideProps() { | ||
const window_dataFetchingScope = typeof window !== 'undefined'; | ||
const document_dataFetchingScope = typeof document !== 'undefined'; | ||
const isWeb_dataFetchingScope = | ||
window_dataFetchingScope && document_dataFetchingScope; | ||
|
||
return { | ||
props: { | ||
isWeb_moduleLoadTime, | ||
window_moduleLoadTime, | ||
document_moduleLoadTime, | ||
window_dataFetchingScope: typeof window !== 'undefined', | ||
document_dataFetchingScope: typeof document !== 'undefined', | ||
window_dataFetchingScope, | ||
document_dataFetchingScope, | ||
isWeb_dataFetchingScope, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters