Add a test helper to build the svg document

This commit is contained in:
2025-06-16 22:41:31 -07:00
parent 4380d10dde
commit 49e09fbc21
2 changed files with 8 additions and 4 deletions

View File

@@ -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;
}