Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should go to next page", async () => {
jsdom.changeURL(window, "http://example.com");
const chapterPosition = element.querySelector(".chapter-position") as HTMLSpanElement;
const iframe = element.querySelector("iframe") as HTMLIFrameElement;
paginatorCurrentPage = 4;
// If you're not on the last page, it goes to the next page.
eventHandler.onRightTap(new UIEvent("mouseup"));
expect(onLastPage.callCount).to.equal(1);
expect(goToNextPage.callCount).to.equal(1);
expect(chapterPosition.innerHTML).to.equal("Page 4 of 8");
await pause();
expect(saveLastReadingPosition.callCount).to.equal(2);
expect(saveLastReadingPosition.args[1][0]).to.deep.equal({
resource: "http://example.com/start.html",
position: 0.25
export default (code: string, userOptions: RunInNewContextType = {}, windowUrl?: string): any => {
const window = jsdom.jsdom('').defaultView;
if (windowUrl) {
jsdom.changeURL(window, windowUrl);
}
const sandbox = {
console,
document: window.document,
ISOMORPHIC_WEBPACK: true,
process: {
env: {
// eslint-disable-next-line no-process-env
NODE_ENV: process.env.NODE_ENV
}
},
require,
window
};
test('browser.parseURL parses current URL with query string', (t) => {
jsdom.changeURL(window, 'https://auth.kevinlin.info?redirect=https://google.com');
const parsed = browser.parseURL();
t.equal(parsed.host, 'auth.kevinlin.info', 'Host is parsed');
t.equal(parsed.query.redirect, 'https://google.com', 'Query string redirect is parsed');
t.end();
});
test('browser.hash sets the current URL hash', (t) => {
jsdom.changeURL(window, 'https://google.com');
browser.hash('hash');
t.equal(window.location.href, 'https://google.com/#hash', 'Hash value is set on URL');
t.end();
});
lab.test('it handles clearReturnUrl', (done) => {
const location = global.window.location.toString();
const query = global.window.location.search;
const url = location.replace(query, '');
Jsdom.changeURL(global.window, url);
const localStorage = global.window.localStorage;
global.window.localStorage = {
removeItem: function () {
global.window.localStorage = localStorage;
done();
}
};
ReturnUrlActions.clearReturnUrl();
});
});
const setURL = (url) => {
jsdom.changeURL(window, url);
Url.reset();
Language.reset();
};
beforeEach(() => {
jsdom.changeURL(window, "https://example.com");
mockNavigatorAPI();
store = new MemoryStore();
element = document.createElement("div");
});