Skip to content

Commit 8a92b6f

Browse files
authored
Merge pull request #7 from remix-run/jacob/abort
test: added more tests for request signal
2 parents 960a10d + 1310aa6 commit 8a92b6f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/fetch/test/request.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,25 @@ describe('Request', () => {
113113
expect(derivedRequest.signal).to.equal(null);
114114
});
115115

116+
it('should abort signal', () => {
117+
const controller = new AbortController();
118+
const request = new Request(base, {
119+
signal: controller.signal,
120+
});
121+
controller.abort();
122+
expect(request.signal.aborted).to.equal(true);
123+
});
124+
125+
it('should abort signal after clone', () => {
126+
const controller = new AbortController();
127+
const request = new Request(base, {
128+
signal: controller.signal,
129+
});
130+
controller.abort();
131+
const clonedRequest = request.clone();
132+
expect(clonedRequest.signal.aborted).to.equal(true);
133+
});
134+
116135
it('should throw error with GET/HEAD requests with body', () => {
117136
expect(() => new Request(base, {body: ''}))
118137
.to.throw(TypeError);

0 commit comments

Comments
 (0)