Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sam Richard
committed
Oct 10, 2017
1 parent
419b8e2
commit fe72a8d
Showing
2 changed files
with
37 additions
and
2 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
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,32 @@ | ||
import test from 'ava'; | ||
import puppeteer from 'puppeteer'; | ||
import server from '../test-server'; | ||
|
||
// Set up a new server for each test | ||
test.cb.beforeEach(t => { | ||
t.context.port = ~~(Math.random() * 1000) + 8000; // eslint-disable-line no-param-reassign | ||
t.context[`server-${t.context.port}`] = server.listen(t.context.port, 'localhost', () => { // eslint-disable-line no-param-reassign | ||
t.end(); | ||
}); | ||
}); | ||
|
||
// Break down server after each test | ||
test.afterEach.cb(t => { | ||
t.context[`server-${t.context.port}`].close(); | ||
t.end(); | ||
}); | ||
|
||
test('Today has focus', async t => { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
await page.goto(`http://localhost:${t.context.port}`); | ||
await page.press('Tab'); | ||
|
||
const active = await page.evaluate(() => { | ||
return document.activeElement; | ||
}); | ||
|
||
await browser.close(); | ||
|
||
t.is(active._prevClass, 'calendar__link'); | ||
}); |