mirror of
https://github.com/webslides/WebSlides.git
synced 2025-08-26 06:24:28 +02:00
New test: goNext, testing after waiting some ms
This commit is contained in:
@@ -3,6 +3,9 @@ import test from 'ava';
|
|||||||
|
|
||||||
let ph_, page_, status_;
|
let ph_, page_, status_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions
|
||||||
|
*/
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
const log = console.log;
|
const log = console.log;
|
||||||
const nolog = function() {};
|
const nolog = function() {};
|
||||||
@@ -21,9 +24,20 @@ const load = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const timeout = async ms => {
|
const timeout = async ms => {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onlyOneVisible = async t => {
|
||||||
|
await page_
|
||||||
|
.evaluate( () => window.ws.slides.filter(
|
||||||
|
slide => slide.el.style.display != 'none'
|
||||||
|
).length == 1 )
|
||||||
|
.then( ok => { t.true(ok); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests
|
||||||
|
*/
|
||||||
test.serial("Page loaded", async t => {
|
test.serial("Page loaded", async t => {
|
||||||
await load();
|
await load();
|
||||||
t.is(status_, 'success');
|
t.is(status_, 'success');
|
||||||
@@ -32,49 +46,44 @@ test.serial("Page loaded", async t => {
|
|||||||
test.serial('#webslides exits', async t => {
|
test.serial('#webslides exits', async t => {
|
||||||
await page_
|
await page_
|
||||||
.evaluate( () => document.querySelector('#webslides') != null )
|
.evaluate( () => document.querySelector('#webslides') != null )
|
||||||
.then( ok => { t.truthy(ok); } );
|
.then( ok => { t.true(ok); } );
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial('WebSlides object exits', async t => {
|
test.serial('WebSlides object exits', async t => {
|
||||||
await page_
|
await page_
|
||||||
.evaluate( () => window.ws != null )
|
.evaluate( () => window.ws != null )
|
||||||
.then( ok => { t.truthy(ok); } );
|
.then( ok => { t.true(ok); } );
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial('Has slides', async t => {
|
test.serial('Has slides', async t => {
|
||||||
await page_
|
await page_
|
||||||
.evaluate( () => window.ws.slides.length > 0 )
|
.evaluate( () => window.ws.slides.length > 0 )
|
||||||
.then( ok => { t.truthy(ok); } );
|
.then( ok => { t.true(ok); } );
|
||||||
});
|
});
|
||||||
|
|
||||||
test.serial('First slide visible', async t => {
|
test.serial('First slide visible', async t => {
|
||||||
await page_
|
await page_
|
||||||
.evaluate( () => window.ws.slides[0].el.style.display != 'none' )
|
.evaluate( () => window.ws.slides[0].el.style.display != 'none' )
|
||||||
.then( ok => { t.truthy(ok); } );
|
.then( ok => { t.true(ok); } );
|
||||||
});
|
});
|
||||||
|
|
||||||
const onlyOneVisible = async t => {
|
|
||||||
await page_
|
|
||||||
.evaluate( () => window.ws.slides.filter(
|
|
||||||
slide => slide.el.style.display != 'none'
|
|
||||||
).length == 1 )
|
|
||||||
.then( ok => { t.truthy(ok); } );
|
|
||||||
}
|
|
||||||
test.serial('Has only one slide visible', onlyOneVisible);
|
test.serial('Has only one slide visible', onlyOneVisible);
|
||||||
/*
|
|
||||||
test.serial('goNext', async t => {
|
test.serial('goNext', async t => {
|
||||||
await page_
|
// First needs to execute the function
|
||||||
|
page_
|
||||||
.evaluate( () => {
|
.evaluate( () => {
|
||||||
//console.log(window.ws.goNext);
|
|
||||||
const ant = window.ws.slides[1].el.style.display+'...';
|
|
||||||
window.ws.goNext();
|
window.ws.goNext();
|
||||||
//await timeout(1000);
|
return true;
|
||||||
console.log(68, window.ws.slides[1].el.style.display);
|
});
|
||||||
return ant;
|
// Then wait
|
||||||
return window.ws.slides[1].el.style.display;
|
await timeout(600);
|
||||||
}).then( ok => { t.truthy(ok); } );
|
// Finally test
|
||||||
|
await page_
|
||||||
|
.evaluate( () => window.ws.slides[1].el.style.display != 'none' )
|
||||||
|
.then( ok => { t.true(ok); } );
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
test.serial('Has only one slide visible', onlyOneVisible);
|
test.serial('Has only one slide visible', onlyOneVisible);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user