Skip to content

Commit f19c1ea

Browse files
author
Sergey Khomushin
committed
improve the test coverage
1 parent 347e046 commit f19c1ea

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { EmailJSResponseStatus } from './EmailJSResponseStatus';
2+
3+
it('should handle the success response', () => {
4+
const error = new EmailJSResponseStatus({
5+
status: 200,
6+
responseText: 'OK',
7+
} as XMLHttpRequest);
8+
9+
expect(error).toEqual({
10+
status: 200,
11+
text: 'OK',
12+
});
13+
});
14+
15+
it('should handle the fail response', () => {
16+
const error = new EmailJSResponseStatus({
17+
status: 404,
18+
responseText: 'No Found',
19+
} as XMLHttpRequest);
20+
21+
expect(error).toEqual({
22+
status: 404,
23+
text: 'No Found',
24+
});
25+
});
26+
27+
it('should handle the null response', () => {
28+
const error = new EmailJSResponseStatus(null);
29+
30+
expect(error).toEqual({
31+
status: 0,
32+
text: 'Network Error',
33+
});
34+
});

src/models/EmailJSResponseStatus.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export class EmailJSResponseStatus {
44

55
constructor(httpResponse: XMLHttpRequest | null) {
66
this.status = httpResponse?.status || 0;
7-
this.text = httpResponse?.responseText || 'network error';
7+
this.text = httpResponse?.responseText || 'Network Error';
88
}
99
}

0 commit comments

Comments
 (0)