Commit f4c007dd authored by julien's avatar julien
Browse files

added test for the string second argument

parent 664df7b7
Pipeline #360 passed with stage
in 4 minutes and 21 seconds
const TIMEOUT = 10000; // Some book might take longer than this to renderer
describe('default', async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage('default/default.html')
return page.rendered;
}, TIMEOUT)
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
})
it('should render text', async () => {
let text = await page.evaluate(() => document.body.textContent);
expect(text).toContain('Chapter 1. Loomings.');
})
it('should render 1 page', async () => {
let pages = await page.$$eval(".pagedjs_page", (r) => r.length);
expect(pages).toBe(5);
})
describe("first", async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage("string/string-first.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
it('should create a pdf', async () => {
let pdf = await page.pdf(PDF_SETTINGS);
await page.close();
}
});
it("should set the running header as \"aaa\" on the first page", async () => {
let text = await page.$eval(".pagedjs_first_page", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"aaa\"");
});
it("should set the running header as \"fff\" on the second page", async () => {
let text = await page.$eval("#page-2", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"fff\"");
});
});
describe("last", async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage("string/string-last.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should set the running header as \"fff\" on the first page", async () => {
let text = await page.$eval(".pagedjs_first_page", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"fff\"");
});
it("should set the running header as \"fff\" on the second page", async () => {
let text = await page.$eval("#page-2", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"fff\"");
});
});
expect(pdf).toMatchPDFSnapshot(1);
})
describe("first-except", async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage("string/string-first-except.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
}
)
});
it("should set the running header as nothing on the first page", async () => {
let text = await page.$eval(".pagedjs_first_page", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"\"");
});
it("should set the running header as \"aaa\" on the second page", async () => {
let text = await page.$eval("#page-2", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"aaa\"");
});
});
describe("string-start", async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage("string/string-start.html");
return page.rendered;
}, TIMEOUT);
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
});
it("should set the running header as nothing on the first page", async () => {
let text = await page.$eval(".pagedjs_first_page", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"aaa\"");
});
it("should set the running header as \"fff\" on the third page", async () => {
let text = await page.$eval("#page-3", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"fff\"");
});
it("should set the running header as \"ggg\" on page 4", async () => {
let text = await page.$eval("#page-4", (r) =>
window.getComputedStyle(r).getPropertyValue("--pagedjs-string-alphabet"));
expect(text).toEqual("\"ggg\"");
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment