Skip to content

Commit

Permalink
fix: test snapshot hash replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
rturnq committed Apr 11, 2024
1 parent 25dd84f commit fdc05bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logo from "./logo.svg";

class {
onCreate() {
this.state = {
clickCount: 0,
mounted: false
mounted: false,
};
}
onMount() {
Expand All @@ -16,10 +15,6 @@ class {
}
}

<div#clickable onClick("handleClick")>
Mounted: ${state.mounted}
Clicks: ${state.clickCount}

LOGO_PATH: ${logo.replace(/-[a-z0-9]+(\.\w+)$/i, '-[hash]$1')}
ENV: ${import.meta.env.BASE_URL}
<div onClick("handleClick") id="clickable">
Mounted: ${state.mounted} Clicks: ${state.clickCount} LOGO_PATH: ${logo} ENV: ${import.meta.env.BASE_URL}
</div>
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
class {
onCreate() {
this.state = {
modulePreloads: []
modulePreloads: [],
};
}
onMount() {
this.state.modulePreloads = document.querySelectorAll('link[rel="modulepreload"]');
this.state.modulePreloads = document.querySelectorAll(
'link[rel="modulepreload"]',
);
}
}

<for|link| of=state.modulePreloads>
<div>PRELOAD: ${new URL(link.href).pathname.replace(/-[a-z0-9]+(\.\w+)$/i, '-[hash]$1')}</div>
<div>PRELOAD: ${new URL(link.href).pathname}</div>
</for>
2 changes: 1 addition & 1 deletion src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ before(async () => {
const formatted = defaultSerializer(
defaultNormalizer(JSDOM.fragment(html)),
)
.replace(/-[a-z0-9_]+(\.\w+)/gi, "-[hash]$1")
.replace(/-[a-z0-9_-]+(\.\w+)/gi, "-[hash]$1")
.replace(/[?&][tv]=[\d.]+/, "");

if (changes.at(-1) !== formatted) {
Expand Down

0 comments on commit fdc05bb

Please sign in to comment.