forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus_code_spec.js
More file actions
37 lines (30 loc) · 1.09 KB
/
status_code_spec.js
File metadata and controls
37 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require('../spec_helper')
const statusCode = require(`../../lib/util/status_code`)
describe('lib/util/status_code', () => {
context('.isOk', () => {
it('numbers starting with 2xx and 3xx returns true', () => {
return [200, 300, 301, 299, 302, 201, '200', '300'].forEach((code) => {
expect(statusCode.isOk(code), `expected status code: ${code} to be true`).to.be.true
})
})
it('numbers not starting with 2xx or 3xx returns false', () => {
return [100, 400, 401, 500, 404, 503, '200a', '300b'].forEach((code) => {
expect(statusCode.isOk(code), `expected status code: ${code} to be false`).to.be.false
})
})
})
context('.getText', () => {
it('is OK', () => {
expect(statusCode.getText(200)).to.eq('OK')
})
it('is Not Found', () => {
expect(statusCode.getText(404)).to.eq('Not Found')
})
it('is Server Error', () => {
expect(statusCode.getText(500)).to.eq('Internal Server Error')
})
it('is Unknown Status Code', () => {
expect(statusCode.getText(1234)).to.eq('Unknown Status Code')
})
})
})