-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from kaimallea/dont-ref-window
fix: stop referencing window
- Loading branch information
Showing
5 changed files
with
396 additions
and
26 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 +1,9 @@ | ||
module.exports = require('@spotify/web-scripts/config/jest.config.js'); | ||
module.exports = { | ||
roots: ['<rootDir>/src/__tests__'], | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
}, | ||
testRegex: '^.+\\.ts$', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
preset: 'jest-puppeteer', | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import puppeteer from 'puppeteer'; | ||
import { isMobileResult } from '..'; | ||
|
||
describe('E2E Tests', () => { | ||
test('isMobile global variable is present', async () => { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
await page.setUserAgent('okhttp/3.0.0'); | ||
await page.addScriptTag({ path: './dist/isMobile.min.js' }); | ||
|
||
const isMobile: isMobileResult = await page.evaluate(() => isMobile); | ||
|
||
expect(isMobile).toMatchInlineSnapshot(` | ||
Object { | ||
"amazon": Object { | ||
"device": false, | ||
"phone": false, | ||
"tablet": false, | ||
}, | ||
"android": Object { | ||
"device": true, | ||
"phone": false, | ||
"tablet": false, | ||
}, | ||
"any": true, | ||
"apple": Object { | ||
"device": false, | ||
"ipod": false, | ||
"phone": false, | ||
"tablet": false, | ||
}, | ||
"other": Object { | ||
"blackberry": false, | ||
"blackberry10": false, | ||
"chrome": false, | ||
"device": false, | ||
"firefox": false, | ||
"opera": false, | ||
}, | ||
"phone": false, | ||
"tablet": false, | ||
"windows": Object { | ||
"device": false, | ||
"phone": false, | ||
"tablet": false, | ||
}, | ||
} | ||
`); | ||
|
||
await browser.close(); | ||
}); | ||
}); |
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
Oops, something went wrong.