Skip to content

Commit 54cf7f3

Browse files
stas-pavlovpimterry
authored andcommitted
Add tests
1 parent df90680 commit 54cf7f3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/integration/matchers/method-path-matching.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,30 @@ responses by hand.`);
120120
await expect(result).to.have.responseText('Fake file');
121121
});
122122

123+
it("should regex match requests for a matching full URL", async () => {
124+
await server.forGet(/localhost:\d+\/[\w\-]+.txt/).thenReply(200, 'Fake file');
125+
126+
let result = await fetch(server.urlFor('/matching-file.txt'));
127+
128+
await expect(result).to.have.responseText('Fake file');
129+
});
130+
131+
it("should regex match requests for a matching URL with negative regexp -- pass", async () => {
132+
await server.forGet(/^(?!.*localhost)/).thenReply(200, 'Fake file');
133+
134+
let result = await fetch(server.urlFor('/matching-file.txt'));
135+
136+
await expect(result).to.have.responseText('Fake file');
137+
});
138+
139+
it("should regex match requests for a matching URL with negative regexp -- catch", async () => {
140+
await server.forGet().withUrlMatching(/^(?!.*localhost)/).thenReply(200, 'Fake file');
141+
142+
let result2 = await fetch(server.urlFor('/matching-file.txt'));
143+
144+
await expect(result2).to.have.responseText(/^.*No rules*./);
145+
});
146+
123147
it("should reject requests for the wrong path", async () => {
124148
await server.forGet("/specific-endpoint").thenReply(200, "mocked data");
125149

@@ -135,6 +159,7 @@ responses by hand.`);
135159

136160
expect(result.status).to.equal(503);
137161
});
162+
138163

139164
it("should match requests ignoring the query string", async () => {
140165
await server.forGet('/path').thenReply(200, 'Matched path');

0 commit comments

Comments
 (0)