Commit 6cae0708 authored by Fred Chasen's avatar Fred Chasen

Add target tests

parent 2a7e08fe
Pipeline #47 failed with stage
This diff is collapsed.
const TIMEOUT = 10000; // Some book might take longer than this to renderer
describe('target-counter', async () => {
let page;
let rendered;
beforeAll(async () => {
page = await loadPage('target/target-counter/target-counter.html')
return page.rendered;
}, TIMEOUT)
afterAll(async () => {
if (!DEBUG) {
await page.close();
}
})
it('Cross reference should include See p. text', async () => {
let text = await page.$eval("#ref-call", (r) => window.getComputedStyle(r, '::after').content);
expect(text).toContain("(See p. ");
})
if (!DEBUG) {
it('should create a pdf', async () => {
let pdf = await page.pdf(PDF_SETTINGS);
expect(pdf).toMatchPDFSnapshot(1);
})
}
}
)
......@@ -93,7 +93,7 @@ class TargetCounters extends Handler {
}
// this.styleSheet.insertRule(`[data-target-counter="${selector}"]${psuedo} { content: "${pg}"; }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-target-counter="${selector}"] { ${target.variable}: "${pg}" }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-target-counter="${selector}"]${psuedo} { ${target.variable}: "${pg}" }`, this.styleSheet.cssRules.length);
}
}
});
......
......@@ -76,8 +76,15 @@ class TargetText extends Handler {
if (split.length > 1) {
psuedo += "::" + split[1];
}
// this.styleSheet.insertRule(`[data-target-text="${selector}"]${psuedo} { content: "${element.textContent}"; }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-target-text="${selector}"]${psuedo} { ${target.variable}: "${element.textContent.trim()}" }`, this.styleSheet.cssRules.length);
let textContent = element.textContent.trim().replace(/[\"\']/g, (match) => {
return "\\" + match;
}).replace(/[\n]/g, (match) => {
return "\\00000A";
});
// this.styleSheet.insertRule(`[data-target-text="${selector}"]${psuedo} { content: "${element.textContent}" }`, this.styleSheet.cssRules.length);
this.styleSheet.insertRule(`[data-target-text="${selector}"]${psuedo} { ${target.variable}: "${textContent}" }`, this.styleSheet.cssRules.length);
}
} else {
......
......@@ -235,7 +235,6 @@ export default `
.pagedjs_pages .pagedjs_margin .pagedjs_margin-content {
width: 100%;
height: 100%;
}
.pagedjs_pages .pagedjs_margin-left .pagedjs_margin-content::after,
......
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