This repository has been archived by the owner on Feb 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Setup jest (& mocks) and test for getStatus
- Loading branch information
Showing
10 changed files
with
42 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"items":[{"key":{"id":776158581,"version":10,"primaryKey":"776158581-1479649399532","created":1479649399532},"services":["9000002000750"],"events":[{"key":"undelivered.advised-addressee_absent_message_left","location":{"fr":"ANTWERPEN DAM MAIL","nl":"ANTWERPEN DAM MAIL","en":"ANTWERPEN DAM MAIL"},"date":"2016-11-22","time":"12:28","irregularity":false},{"key":"taken-on-round-out_for_distribution","location":{"fr":"ANTWERPEN DAM MAIL","nl":"ANTWERPEN DAM MAIL","en":"ANTWERPEN DAM MAIL"},"date":"2016-11-22","time":"07:23","irregularity":false},{"key":"sorted-sorted_out","location":{"fr":"Antwerpen X Parcel Sorter","nl":"Antwerpen X Parcel Sorter","en":"Antwerpen X Parcel Sorter"},"date":"2016-11-21","time":"18:21","irregularity":false},{"key":"N-SENT-OTHER","date":"2016-11-21","time":"10:30","irregularity":false},{"key":"received.domestic-corner","location":{"fr":"PP OCTA+ SINT KRUIS","nl":"PP OCTA+ SINT KRUIS","en":"PP OCTA+ SINT KRUIS"},"date":"2016-11-21","time":"10:18","irregularity":false},{"key":"announcement.normal-announced_parcel_by_customer","location":{"fr":"","nl":"","en":""},"date":"2016-11-20","time":"14:43","irregularity":false}],"itemCode":"323267009999171004","sender":{"countryCode":"BE","postcode":"8310","municipality":"SINT-KRUIS"},"receiver":{"name":"DE CALUWE DURVASA","countryCode":"BE","postcode":"2060","municipality":"ANTWERPEN"},"customerReference":"1493998-12","deliveryPoint":{"name":{"fr":"POSTPUNT Q8 ANTWERPEN","nl":"POSTPUNT Q8 ANTWERPEN","en":"POSTPUNT Q8 ANTWERPEN"},"id":"806480","type":"POSTAL_POINT","street":{"fr":"Schijnpoortweg","nl":"Schijnpoortweg","en":"Schijnpoortweg"},"streetNumber":{"fr":"18","nl":"18","en":"18"},"postcode":{"fr":"2060","nl":"2060","en":"2060"},"openingSchedules":[{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"MONDAY"},{"openingHours":[],"dayOfTheWeek":"TUESDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"WEDNESDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"THURSDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"FRIDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"SATURDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"SUNDAY"}],"longitude":4.43789,"latitude":51.22692,"municipality":{"fr":"Antwerpen","nl":"Antwerpen","en":"Antwerpen"},"showMap":true},"weightInGrams":480,"product":"2000000191034","productCategory":"parcel","processOverview":{"processSteps":[{"name":"prepare","status":"completed","label":{"main":"preparation","detail":"bySender"},"knownProcessStep":"IN_PREPARATION"},{"name":"processing","status":"completed","label":{"main":"processing","detail":"byBpost"},"knownProcessStep":"PROCESSING"},{"name":"out_for_delivery","status":"active","label":{"main":"onTheWay","detail":"toPostPoint"},"knownProcessStep":"ON_THE_WAY_TO_POST_POINT"},{"name":"post_point","status":"upcoming","label":{"main":"available","detail":"inPostPoint"},"knownProcessStep":"AVAILABLE_IN_POST_POINT_INTERNATIONAL"},{"name":"delivered","status":"upcoming","label":{"main":"pickedUp","detail":"inPostPoint"},"knownProcessStep":"PICKED_UP_IN_POST_POINT_INTERNATIONAL"}],"activeStepTextKey":"OUT_FOR_DELIVERY_POST_POINT","textKey":"step.text.out_for_delivery.post_point","alert":false},"contactForMoreInformation":"BPOST","signatureViewType":"NONE","requestedDeliveryMethod":"HOME","inNetworkDate":"2016-11-21","earliestAvailableTime":{"time":"11:00","day":"2016-11-23"},"latestAvailableTime":{"time":"22:00","day":"2016-12-07"},"attemptedDeliveryTime":{"time":"12:28","day":"2016-11-22"},"faqs":[{"id":"faqid_2","title":{"fr":"Quid si je ne suis pas chez moi lorsque le facteur vient livrer mon paquet ?","nl":"Wat als ik niet thuis ben als de postbode mijn pakje komt afleveren?","en":"What if I am not home when the parcel is delivered?"}},{"id":"faqid_4","title":{"fr":"Comment puis-je demander une deuxième présentation ?","nl":"Hoe kan ik een tweede aanbieding aanvragen?","en":"How do I request a second delivery attempt?"}},{"id":"faqid_33","title":{"fr":"Où est mon colis ?","nl":"Waar is mijn pakje?","en":"Where is my parcel?"}}],"retourOrBackToSender":false}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"items":[{"key":{"id":776158581,"version":12,"primaryKey":"776158581-1479649399532","created":1479649399532},"services":["9000002000750"],"events":[{"key":"distribution.normal-regular","location":{"fr":"PP Q8 ANTWERPEN","nl":"PP Q8 ANTWERPEN","en":"PP Q8 ANTWERPEN"},"date":"2016-11-23","time":"13:37","irregularity":false},{"key":"arrival.pickup-point-drop_off_postman","location":{"fr":"PP Q8 ANTWERPEN","nl":"PP Q8 ANTWERPEN","en":"PP Q8 ANTWERPEN"},"date":"2016-11-23","time":"09:10","irregularity":false},{"key":"undelivered.advised-addressee_absent_message_left","location":{"fr":"ANTWERPEN DAM MAIL","nl":"ANTWERPEN DAM MAIL","en":"ANTWERPEN DAM MAIL"},"date":"2016-11-22","time":"12:28","irregularity":false},{"key":"taken-on-round-out_for_distribution","location":{"fr":"ANTWERPEN DAM MAIL","nl":"ANTWERPEN DAM MAIL","en":"ANTWERPEN DAM MAIL"},"date":"2016-11-22","time":"07:23","irregularity":false},{"key":"sorted-sorted_out","location":{"fr":"Antwerpen X Parcel Sorter","nl":"Antwerpen X Parcel Sorter","en":"Antwerpen X Parcel Sorter"},"date":"2016-11-21","time":"18:21","irregularity":false},{"key":"N-SENT-OTHER","date":"2016-11-21","time":"10:30","irregularity":false},{"key":"received.domestic-corner","location":{"fr":"PP OCTA+ SINT KRUIS","nl":"PP OCTA+ SINT KRUIS","en":"PP OCTA+ SINT KRUIS"},"date":"2016-11-21","time":"10:18","irregularity":false},{"key":"announcement.normal-announced_parcel_by_customer","location":{"fr":"","nl":"","en":""},"date":"2016-11-20","time":"14:43","irregularity":false}],"itemCode":"323267009999171004","sender":{"countryCode":"BE","postcode":"8310","municipality":"SINT-KRUIS"},"receiver":{"name":"DE CALUWE DURVASA","countryCode":"BE","postcode":"2060","municipality":"ANTWERPEN"},"customerReference":"1493998-12","deliveryPoint":{"name":{"fr":"POSTPUNT Q8 ANTWERPEN","nl":"POSTPUNT Q8 ANTWERPEN","en":"POSTPUNT Q8 ANTWERPEN"},"id":"806480","type":"POSTAL_POINT","street":{"fr":"Schijnpoortweg","nl":"Schijnpoortweg","en":"Schijnpoortweg"},"streetNumber":{"fr":"18","nl":"18","en":"18"},"postcode":{"fr":"2060","nl":"2060","en":"2060"},"openingSchedules":[{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"MONDAY"},{"openingHours":[],"dayOfTheWeek":"TUESDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"WEDNESDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"THURSDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"FRIDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"SATURDAY"},{"earliestOpeningHour":"06:00","latestClosingHour":"22:00","openingHours":[{"open":"06:00","close":"22:00"}],"dayOfTheWeek":"SUNDAY"}],"longitude":4.43789,"latitude":51.22692,"municipality":{"fr":"Antwerpen","nl":"Antwerpen","en":"Antwerpen"},"showMap":false},"weightInGrams":480,"product":"2000000191034","productCategory":"parcel","processOverview":{"processSteps":[{"name":"prepare","status":"completed","label":{"main":"preparation","detail":"bySender"},"knownProcessStep":"IN_PREPARATION"},{"name":"processing","status":"completed","label":{"main":"processing","detail":"byBpost"},"knownProcessStep":"PROCESSING"},{"name":"out_for_delivery","status":"completed","label":{"main":"onTheWay","detail":"toPostPoint"},"knownProcessStep":"ON_THE_WAY_TO_POST_POINT"},{"name":"post_point","status":"completed","label":{"main":"available","detail":"inPostPoint"},"knownProcessStep":"AVAILABLE_IN_POST_POINT_INTERNATIONAL"},{"name":"delivered","status":"active","label":{"main":"pickedUp","detail":"inPostPoint"},"knownProcessStep":"PICKED_UP_IN_POST_POINT_INTERNATIONAL"}],"activeStepTextKey":"DELIVERED","textKey":"step.text.delivered","alert":false},"contactForMoreInformation":"BPOST","signatureViewType":"NONE","requestedDeliveryMethod":"HOME","inNetworkDate":"2016-11-21","attemptedDeliveryTime":{"time":"12:28","day":"2016-11-22"},"actualDeliveryTime":{"time":"13:37","day":"2016-11-23"},"faqs":[{"id":"faqid_2","title":{"fr":"Quid si je ne suis pas chez moi lorsque le facteur vient livrer mon paquet ?","nl":"Wat als ik niet thuis ben als de postbode mijn pakje komt afleveren?","en":"What if I am not home when the parcel is delivered?"}},{"id":"faqid_4","title":{"fr":"Comment puis-je demander une deuxième présentation ?","nl":"Hoe kan ik een tweede aanbieding aanvragen?","en":"How do I request a second delivery attempt?"}},{"id":"faqid_33","title":{"fr":"Où est mon colis ?","nl":"Waar is mijn pakje?","en":"Where is my parcel?"}}],"retourOrBackToSender":false}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
exports[`Method: getStatus should return the object for currently active step 1`] = ` | ||
Object { | ||
"knownProcessStep": "PICKED_UP_IN_POST_POINT_INTERNATIONAL", | ||
"label": Object { | ||
"detail": "inPostPoint", | ||
"main": "pickedUp", | ||
}, | ||
"name": "delivered", | ||
"status": "active", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
import * as bpost from '/src/lib/methods/getStatus.js'; | ||
jest.mock(`/__mocks__/composedFetch`); | ||
|
||
const result = { | ||
name: `delivered`, | ||
status: `active`, | ||
label: { | ||
main: `pickedUp`, | ||
detail: `inPostPoint`, | ||
}, | ||
knownProcessStep: `PICKED_UP_IN_POST_POINT_INTERNATIONAL`, | ||
}; | ||
import * as bpost from '../../src/lib/methods/getStatus.js'; | ||
jest.mock(`../../__mocks__/composedFetch`); | ||
|
||
describe(`Method: getStatus`, () => { | ||
it(`should return the object for currently active step`, () => { | ||
return bpost.default(`323267009691651472`) | ||
.then(res => expect(res).toEqual(result)); | ||
it(`should return the object for currently active step`, async () => { | ||
const request = await bpost.default(`323267009691651472`); | ||
expect(request).toMatchSnapshot(); | ||
}); | ||
|
||
it(`should fail if an incorrect id param is passed`, async () => { | ||
const req = await bpost.default(`3D3267OO9691651472`); | ||
expect(req).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import composedFetch from '../src/lib/composedFetch'; | ||
|
||
describe(`Method: composedFetch`, () => { | ||
it(`returns invalid response`, async () => { | ||
const request = await composedFetch(`3232D7OO9691651472`); | ||
expect(request).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters