-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cy.js
74 lines (67 loc) · 3.96 KB
/
test.cy.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// IMPORTANT: Please do not change this file as it is used to calculate the coding test score.
const apiUrl = `${Cypress.env("apiUrl")}`
describe('Lookup Service - Level 1', () => {
it('Provides a functional healthcheck', () => {
cy.request({
failOnStatusCode: false,
method: 'GET',
url: `${apiUrl}/ping`,
}).then((response) => {
assert.equal(response.status, 200, "Ping should return 200 status code")
})
})
it('Can correctly aggregate and return Emma\'s credit data', () => {
cy.request({
failOnStatusCode: false,
method: 'GET',
url: `${apiUrl}/credit-data/424-11-9327`,
}).then((response) => {
assert.equal(response.status, 200, "Getting aggregated credit data for ssn 424-11-9327 should return 200 status code")
assert.equal(response.body.first_name, "Emma", "Data mismatch when returning aggregated credit data for ssn 424-11-9327")
assert.equal(response.body.last_name, "Gautrey", "Data mismatch when returning aggregated credit data for ssn 424-11-9327")
expect(response.body.address).to.match(/\d{1,4} Westend Terrace$/)
assert.equal(response.body.assessed_income, 60668, "Data mismatch when returning aggregated credit data for ssn 424-11-9327")
assert.equal(response.body.balance_of_debt, 11585, "Data mismatch when returning aggregated credit data for ssn 424-11-9327")
assert.equal(response.body.complaints, true, "Data mismatch when returning aggregated credit data for ssn 424-11-9327")
})
})
it('Can correctly aggregate and return Billy\'s credit data', () => {
cy.request({
failOnStatusCode: false,
method: 'GET',
url: `${apiUrl}/credit-data/553-25-8346`,
}).then((response) => {
assert.equal(response.status, 200, "Getting aggregated credit data for ssn 424-11-9327 should return 200 status code")
assert.equal(response.body.first_name, "Billy", "Data mismatch when returning aggregated credit data for ssn 553-25-8346")
assert.equal(response.body.last_name, "Brinegar", "Data mismatch when returning aggregated credit data for ssn 553-25-8346")
expect(response.body.address).to.match(/\d{1,4} Providence Lane La Puente, CA 91744$/)
assert.equal(response.body.assessed_income, 89437, "Data mismatch when returning aggregated credit data for ssn 553-25-8346")
assert.equal(response.body.balance_of_debt, 178, "Data mismatch when returning aggregated credit data for ssn 553-25-8346")
assert.equal(response.body.complaints, false, "Data mismatch when returning aggregated credit data for ssn 553-25-8346")
})
})
it('Can correctly aggregate and return Gail\'s credit data', () => {
cy.request({
failOnStatusCode: false,
method: 'GET',
url: `${apiUrl}/credit-data/287-54-7823`,
}).then((response) => {
assert.equal(response.status, 200, "Getting aggregated credit data for ssn 287-54-7823 should return 200 status code")
assert.equal(response.body.first_name, "Gail", "Data mismatch when returning aggregated credit data for ssn 287-54-7823")
assert.equal(response.body.last_name, "Shick", "Data mismatch when returning aggregated credit data for ssn 287-54-7823")
expect(response.body.address).to.match(/\d{1,4} Rainbow Drive Canton, OH 44702$/)
assert.equal(response.body.assessed_income, 42301, "Data mismatch when returning aggregated credit data for ssn 287-54-7823")
assert.equal(response.body.balance_of_debt, 23087, "Data mismatch when returning aggregated credit data for ssn 287-54-7823")
assert.equal(response.body.complaints, true, "Data mismatch when returning aggregated credit data for ssn 287-54-7823")
})
})
it('Can handle requests for non-existent SSNs', () => {
cy.request({
failOnStatusCode: false,
method: 'GET',
url: `${apiUrl}/credit-data/000-00-0000`,
}).then((response) => {
assert.equal(response.status, 404, "Getting aggregated credit data for non-existent SSN should return 404 status code")
})
})
})