Skip to content

Commit da1f880

Browse files
committed
Mock setup
1 parent c58de78 commit da1f880

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"watch": "tsc --watch",
1010
"build": "tsc -p tsconfig.json",
1111
"dev": "node scripts/dev.js",
12-
"test": "jasmine"
12+
"test": "tsc -b spec && jasmine"
1313
},
1414
"keywords": [],
1515
"author": "",

spec/src/env.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
class Pattern {
3+
private constructor(public string:string){}
4+
regex = new RegExp(this.string);
5+
static compile(regex:string){
6+
return new this(`^${regex}$`);
7+
}
8+
static matches(regex:string, target:string):boolean {
9+
return new RegExp(`^${regex}$`).test(target);
10+
}
11+
matcher(text:string){
12+
return {
13+
replaceAll: (replacement:string) => {
14+
return text.replaceAll(this.regex, replacement);
15+
},
16+
matches: () => {
17+
return this.regex.test(text);
18+
},
19+
group: () => {
20+
throw new Error("not implemented");
21+
}
22+
}
23+
}
24+
}
25+
26+
Object.assign(globalThis, {Pattern});

spec/support/jasmine.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"**/*[sS]pec.?(m)js"
55
],
66
"helpers": [
7-
"helpers/**/*.?(m)js"
7+
"build/env.js"
88
],
99
"env": {
1010
"stopSpecOnExpectationFailure": false,

0 commit comments

Comments
 (0)