@@ -3,27 +3,59 @@ describe('quicklink tests', function () {
33
44 before ( async function ( ) {
55 page = await browser . newPage ( ) ;
6- await page . goto ( 'http://127.0.0.1:8080/demo/index.html' ) ;
6+ // await page.goto('http://127.0.0.1:8080/demo/index.html');
77 } ) ;
88
99 after ( async function ( ) {
1010 await page . close ( ) ;
1111 } ) ;
1212
13- it ( 'should have the correct page title' , async function ( ) {
14- expect ( await page . title ( ) ) . to . eql ( 'Prefetch experiments' ) ;
13+ it ( 'should prefetch in-viewport links correctly (UMD)' , async function ( ) {
14+ const responseURLs = [ ] ;
15+ page . on ( 'response' , resp => {
16+ responseURLs . push ( resp . url ( ) ) ;
17+ } ) ;
18+ await page . goto ( 'http://127.0.0.1:8080/demo/test-basic-usage.html' ) ;
19+ await page . waitFor ( 1000 ) ;
20+ expect ( responseURLs ) . to . be . an ( 'array' ) ;
21+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/2.html' ) ;
22+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/2.html' ) ;
23+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/3.html' ) ;
1524 } ) ;
1625
17- it ( 'should prefetch pages correctly' , async function ( ) {
26+ it ( 'should prefetch in-viewport links correctly (ES Modules) ' , async function ( ) {
1827 const responseURLs = [ ] ;
1928 page . on ( 'response' , resp => {
2029 responseURLs . push ( resp . url ( ) ) ;
2130 } ) ;
22- await page . goto ( 'http://127.0.0.1:8080/demo/index .html' ) ;
31+ await page . goto ( 'http://127.0.0.1:8080/demo/test-es-modules .html' ) ;
2332 await page . waitFor ( 1000 ) ;
2433 expect ( responseURLs ) . to . be . an ( 'array' ) ;
2534 expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/2.html' ) ;
2635 expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/2.html' ) ;
2736 expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/3.html' ) ;
2837 } ) ;
38+
39+ it ( 'should prefetch a static list of URLs correctly' , async function ( ) {
40+ const responseURLs = [ ] ;
41+ page . on ( 'response' , resp => {
42+ responseURLs . push ( resp . url ( ) ) ;
43+ } ) ;
44+ await page . goto ( 'http://127.0.0.1:8080/demo/test-static-url-list.html' ) ;
45+ await page . waitFor ( 1000 ) ;
46+ expect ( responseURLs ) . to . be . an ( 'array' ) ;
47+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/2.html' ) ;
48+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/4.html' ) ;
49+ } ) ;
50+
51+ it ( 'should prefetch in-viewport links from a custom DOM source' , async function ( ) {
52+ const responseURLs = [ ] ;
53+ page . on ( 'response' , resp => {
54+ responseURLs . push ( resp . url ( ) ) ;
55+ } ) ;
56+ await page . goto ( 'http://127.0.0.1:8080/demo/test-custom-dom-source.html' ) ;
57+ await page . waitFor ( 1000 ) ;
58+ expect ( responseURLs ) . to . be . an ( 'array' ) ;
59+ expect ( responseURLs ) . to . include ( 'http://127.0.0.1:8080/demo/main.css' ) ;
60+ } ) ;
2961} ) ;
0 commit comments