Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/integration/helpers.cjs8
-rw-r--r--test/integration/select.test.js4
2 files changed, 8 insertions, 4 deletions
diff --git a/test/integration/helpers.cjs b/test/integration/helpers.cjs
index d38f1b6..10b0dc6 100644
--- a/test/integration/helpers.cjs
+++ b/test/integration/helpers.cjs
@@ -51,10 +51,10 @@ global.page = {
}
};
-global.mockResponse = async function mockResponse(driver, urlPath, template, createFn) {
+global.mockResponse = async function mockResponse(driver, urlPath, template, buildFn) {
const connection = driver.createCDPConnection('page');
const dom = new JSDOM(template);
- const contents = createFn(dom.window.document);
+ const contents = buildFn(dom.window.document);
const httpResponse = new HttpResponse(url(urlPath));
httpResponse.body = contents;
@@ -86,3 +86,7 @@ global.selectCounter = function (counter) {
counter.querySelector('.counter').classList.add('selected');
return counter;
}
+
+global.svgDocument = function (document) {
+ return `<?xml version="1.0" standalone="yes"?>\n` + document.querySelector('svg').outerHTML;
+}
diff --git a/test/integration/select.test.js b/test/integration/select.test.js
index c91165d..588876b 100644
--- a/test/integration/select.test.js
+++ b/test/integration/select.test.js
@@ -27,7 +27,7 @@ describe('a trooper', () => {
beforeEach(async () => {
await mockResponse(driver, `/assets/images/${scenario}`, fixture, (document) => {
placeCounter(document, createTroopCounter(), { x: 1, y: 1 });
- return `<?xml version="1.0" standalone="yes"?>\n` + document.querySelector('svg').outerHTML;
+ return svgDocument(document);
});
});
@@ -73,7 +73,7 @@ describe('a selected trooper', () => {
beforeEach(async () => {
await mockResponse(driver, `/assets/images/${scenario}`, fixture, (document) => {
placeCounter(document, selectCounter(createTroopCounter()), { x: 1, y: 1 });
- return `<?xml version="1.0" standalone="yes"?>\n` + document.querySelector('svg').outerHTML;
+ return svgDocument(document);
});
});