Skip to content

Commit 5506a68

Browse files
committed
refactor: is created validation to use validateHttpStatus helper
1 parent ade108d commit 5506a68

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/is-created.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import validateHttpStatus from './validate-http-status';
2+
3+
const EXPECTED_STATUS = 201;
4+
15
function isCreated(status) {
2-
return status === 201;
6+
return validateHttpStatus(status, EXPECTED_STATUS);
37
}
48

59
export default isCreated;

tests/is-created.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ describe('isCreated', () => {
55
expect(isCreated(201)).toBeTruthy();
66
});
77

8-
test('it should test isCreated status different then 200', () => {
9-
expect(isCreated(200)).toBeFalsy();
8+
test('it should throw Error when pass status different than 201', () => {
9+
const received = isCreated(300);
10+
expect(received.message).toBe('Expected a 201 response.');
1011
});
1112
});

0 commit comments

Comments
 (0)