Skip to content

Commit 82538fc

Browse files
committed
chore: fix linting issues
Signed-off-by: Jakub Freisler <[email protected]>
1 parent c09bab3 commit 82538fc

File tree

3 files changed

+60
-51
lines changed

3 files changed

+60
-51
lines changed

src/commands.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,18 @@ Cypress.Commands.add(
151151
`${res.message}${
152152
res.imgDiffBase64 && res.imgNewBase64 && res.imgOldBase64
153153
? `\n[See comparison](${LINK_PREFIX}${Base64.encode(
154-
encodeURIComponent(
155-
JSON.stringify({
156-
title,
157-
imgPath,
158-
imgDiffBase64: res.imgDiffBase64,
159-
imgNewBase64: res.imgNewBase64,
160-
imgOldBase64: res.imgOldBase64,
161-
error: res.error
162-
})
163-
)
164-
)})`
165-
: ''
154+
encodeURIComponent(
155+
JSON.stringify({
156+
title,
157+
imgPath,
158+
imgDiffBase64: res.imgDiffBase64,
159+
imgNewBase64: res.imgNewBase64,
160+
imgOldBase64: res.imgOldBase64,
161+
error: res.error,
162+
})
163+
)
164+
)})`
165+
: ""
166166
}`
167167
);
168168

src/support.ts

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Base64 from "@frsource/base64";
22
import "./commands";
3-
import { FILE_SUFFIX, LINK_PREFIX, OVERLAY_CLASS, TASK } from "./constants";
3+
import { LINK_PREFIX, OVERLAY_CLASS, TASK } from "./constants";
44

55
/* c8 ignore start */
66
function queueClear() {
@@ -29,7 +29,7 @@ export const generateOverlayTemplate = ({
2929
imgOldBase64: string;
3030
imgDiffBase64: string;
3131
wasImageNotUpdatedYet: boolean;
32-
error: boolean
32+
error: boolean;
3333
}) => `<div class="${OVERLAY_CLASS} runner" style="position:fixed;z-index:10;top:0;bottom:0;left:0;right:0;display:flex;flex-flow:column">
3434
<header style="position:static">
3535
<nav style="display:flex;width:100%;align-items:center;justify-content:space-between;padding:10px 15px;">
@@ -38,7 +38,9 @@ export const generateOverlayTemplate = ({
3838
${
3939
wasImageNotUpdatedYet
4040
? `<button type="submit"><i class="fa fa-check"></i> Update screenshot</button>`
41-
: error ? "Image was already updated, rerun test to see new comparison" : ""
41+
: error
42+
? "Image was already updated, rerun test to see new comparison"
43+
: ""
4244
}
4345
<button type="button" data-type="close"><i class="fa fa-times"></i> Close</button>
4446
<form>
@@ -82,7 +84,14 @@ after(() => {
8284
e.preventDefault();
8385
if (!top) return false;
8486

85-
const { title, imgPath, imgDiffBase64, imgNewBase64, imgOldBase64, error } = JSON.parse(
87+
const {
88+
title,
89+
imgPath,
90+
imgDiffBase64,
91+
imgNewBase64,
92+
imgOldBase64,
93+
error,
94+
} = JSON.parse(
8695
decodeURIComponent(
8796
Base64.decode(
8897
e.currentTarget.getAttribute("href").substring(LINK_PREFIX.length)
@@ -91,40 +100,40 @@ after(() => {
91100
);
92101
queueClear();
93102

94-
cy
95-
.task<boolean>(TASK.doesFileExist, { path: imgPath }, { log: false })
96-
.then(
97-
(wasImageNotUpdatedYet) => {
98-
if (!top) return false;
99-
queueClear();
103+
cy.task<boolean>(
104+
TASK.doesFileExist,
105+
{ path: imgPath },
106+
{ log: false }
107+
).then((wasImageNotUpdatedYet) => {
108+
if (!top) return false;
109+
queueClear();
100110

101-
Cypress.$(
102-
generateOverlayTemplate({
103-
title,
104-
imgNewBase64,
105-
imgOldBase64,
106-
imgDiffBase64,
107-
error,
108-
wasImageNotUpdatedYet,
109-
})
110-
).appendTo(top.document.body);
111+
Cypress.$(
112+
generateOverlayTemplate({
113+
title,
114+
imgNewBase64,
115+
imgOldBase64,
116+
imgDiffBase64,
117+
error,
118+
wasImageNotUpdatedYet,
119+
})
120+
).appendTo(top.document.body);
111121

112-
const wrapper = Cypress.$(`.${OVERLAY_CLASS}`, top.document.body);
113-
wrapper.on("click", 'button[data-type="close"]', function () {
114-
wrapper.remove();
115-
});
122+
const wrapper = Cypress.$(`.${OVERLAY_CLASS}`, top.document.body);
123+
wrapper.on("click", 'button[data-type="close"]', function () {
124+
wrapper.remove();
125+
});
116126

117-
wrapper.on("submit", "form", function (e) {
118-
e.preventDefault();
127+
wrapper.on("submit", "form", function (e) {
128+
e.preventDefault();
119129

120-
cy.task(TASK.approveImage, { img: imgPath }).then(() =>
121-
wrapper.remove()
122-
);
130+
cy.task(TASK.approveImage, { img: imgPath }).then(() =>
131+
wrapper.remove()
132+
);
123133

124-
queueRun();
125-
});
126-
}
127-
);
134+
queueRun();
135+
});
136+
});
128137

129138
queueRun();
130139

src/task.hook.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export const compareImagesTask = async (
105105
}
106106

107107
const diffBuffer = PNG.sync.write(diff);
108-
imgNewBase64 = PNG.sync.write(imgNew).toString('base64');
109-
imgDiffBase64 = diffBuffer.toString('base64');
110-
imgOldBase64 = PNG.sync.write(imgOld).toString('base64');
108+
imgNewBase64 = PNG.sync.write(imgNew).toString("base64");
109+
imgDiffBase64 = diffBuffer.toString("base64");
110+
imgOldBase64 = PNG.sync.write(imgOld).toString("base64");
111111

112112
if (error) {
113113
fs.writeFileSync(
@@ -130,9 +130,9 @@ export const compareImagesTask = async (
130130
} else {
131131
// there is no "old screenshot" or screenshots should be immediately updated
132132
imgDiff = 0;
133-
imgNewBase64 = '';
134-
imgDiffBase64 = '';
135-
imgOldBase64 = '';
133+
imgNewBase64 = "";
134+
imgDiffBase64 = "";
135+
imgOldBase64 = "";
136136
moveFile.sync(cfg.imgNew, cfg.imgOld);
137137
}
138138

0 commit comments

Comments
 (0)