Skip to content

Commit 6348427

Browse files
committed
test: add more unit tests
1 parent 464a1ce commit 6348427

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ hash({
124124

125125
```js
126126
hash({
127-
pattern: new RegExp(/\custom-file-pattern/),
127+
pattern: new RegExp(/custom-file-pattern/),
128128
hashLength: 8,
129129
});
130130
```

src/tests/plugin.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ test.equal(
7676
"script.b0dcc67f.js"
7777
);
7878

79+
const CUSTOM_EXP_3 = new RegExp(/custom-hash/);
80+
81+
test.equal(
82+
replaceHash(
83+
"script.custom-hash.js",
84+
buffer,
85+
CUSTOM_EXP_3,
86+
DEFAULT_HASH_LENGTH
87+
),
88+
"script.b0dcc67ffc1fd562f212.js"
89+
);
90+
test.equal(
91+
replaceHash("script.custom-hash.js", buffer, CUSTOM_EXP_3, 4),
92+
"script.b0dc.js"
93+
);
94+
7995
function copyFixture(fileName: string) {
8096
const file = path.join(__dirname, "__fixtures__/original", fileName);
8197
fs.copyFileSync(

0 commit comments

Comments
 (0)