-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π fix initializing with jQuery bridget
add min.js
- Loading branch information
Showing
5 changed files
with
89 additions
and
5 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,54 @@ | ||
const test = require('ava'); | ||
const puppeteer = require('puppeteer'); | ||
const getServer = require('./_get-server.js'); | ||
|
||
const port = 9011; | ||
let server, browser, page; | ||
|
||
test.before( async function() { | ||
server = getServer(); | ||
server.listen( port ); | ||
browser = await puppeteer.launch(); | ||
page = await browser.newPage(); | ||
await page.goto(`http://localhost:${port}/test/html/dist-jquery.html`); | ||
} ); | ||
|
||
test.after( async function() { | ||
page.close(); | ||
await browser.close(); | ||
server.close(); | ||
} ); | ||
|
||
// ------ tests ------ // | ||
|
||
test( 'dist jQuery', async( t ) => { | ||
|
||
let assertions = await page.evaluate( function() { | ||
const { jQuery } = window; | ||
let $container = document.querySelector('.container'); | ||
$container = jQuery('.container').infiniteScroll({ | ||
path: 'page/{{#}}.html', | ||
append: '.post', | ||
}); | ||
|
||
let infScroll = $container.data('infinite-scroll'); | ||
|
||
return $container.infiniteScroll('loadNextPage') | ||
.then( function( load ) { | ||
let { response, body, items } = load; | ||
serialT.true( response instanceof Response ); | ||
serialT.true( response.ok ); | ||
serialT.is( response.status, 200 ); | ||
serialT.true( body instanceof HTMLDocument ); | ||
serialT.true( items instanceof NodeList ); | ||
serialT.is( items.length, 2 ); | ||
serialT.true( items[0] == $container[0].children[1] ); | ||
serialT.true( items[1] == $container[0].children[2] ); | ||
serialT.is( infScroll.pageIndex, 2 ); | ||
serialT.is( infScroll.loadCount, 1 ); | ||
} ) | ||
.then( () => serialT.assertions ); | ||
} ); | ||
|
||
assertions.forEach( ({ method, args }) => t[ method ]( ...args ) ); | ||
} ); |
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,28 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
|
||
<title>Infinite Scroll test - dist jQuery</title> | ||
|
||
<link rel="stylesheet" href="test.css" /> | ||
|
||
<!-- dependencies --> | ||
<script src="../../node_modules/jquery/dist/jquery.js"></script> | ||
<script src="../../dist/infinite-scroll.pkgd.min.js"></script> | ||
<!-- test helper --> | ||
<script src="_serial-t.js"></script> | ||
|
||
</head> | ||
<body> | ||
|
||
<h1>Infinite Scroll test - dist jQuery</h1> | ||
|
||
<div class="container"> | ||
<div class="post">page 1, post 1</div> | ||
</div> | ||
<p><a class="next-link" href="page/2.html">Next</a></p> | ||
|
||
</body> | ||
</html> |