test: split out dialog tests (#3586)

This commit is contained in:
Andrey Lushnikov
2018-11-20 20:18:57 -08:00
committed by GitHub
parent 309cbe625f
commit 6656519560
5 changed files with 68 additions and 46 deletions

View File

@@ -189,13 +189,6 @@ module.exports.addTests = function({testRunner, expect, headless}) {
});
});
describe('Page.evaluateHandle', function() {
it('should work', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => window);
expect(windowHandle).toBeTruthy();
});
});
describe('ExecutionContext.queryObjects', function() {
it('should work', async({page, server}) => {
// Instantiate an object
@@ -498,35 +491,6 @@ module.exports.addTests = function({testRunner, expect, headless}) {
});
});
describe('Page.Events.Dialog', function() {
it('should fire', async({page, server}) => {
page.on('dialog', dialog => {
expect(dialog.type()).toBe('alert');
expect(dialog.defaultValue()).toBe('');
expect(dialog.message()).toBe('yo');
dialog.accept();
});
await page.evaluate(() => alert('yo'));
});
it('should allow accepting prompts', async({page, server}) => {
page.on('dialog', dialog => {
expect(dialog.type()).toBe('prompt');
expect(dialog.defaultValue()).toBe('yes.');
expect(dialog.message()).toBe('question?');
dialog.accept('answer!');
});
const result = await page.evaluate(() => prompt('question?', 'yes.'));
expect(result).toBe('answer!');
});
it('should dismiss the prompt', async({page, server}) => {
page.on('dialog', dialog => {
dialog.dismiss();
});
const result = await page.evaluate(() => prompt('question?'));
expect(result).toBe(null);
});
});
describe('Page.Events.PageError', function() {
it('should fire', async({page, server}) => {
let error = null;