apc-domain
Version:
APC Domain Information Package
122 lines (84 loc) • 4.62 kB
JavaScript
// Test that an ND will not deliver on a weekend
// Send it on a friday and assert it'll come on Monday
// Test that an ND will deliver on a working day during the week
// Send it on a monday and assert it'll come on Tuesday
// Test that an NS sent on a Friday will deliver on Saturday (next one)
// Test that an NS sent on a Thursday will arrive on a Saturday? (next one)
const chai = require('chai')
const Services = require('../src/Services.js')
const Moment = require('moment')
/**
* Test next day services
*/
describe ('Test ND/CP/MP (NextDay, CourierPack, MailPack) Behaviour', async () => {
// Test ND collected on Monday, Delivers Tuesday
it ('Should Deliver on Tuesday if Collected Monday', async () => {
let ShipDate = '25-11-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('ND09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('26-11-2019')
})
// Test ND collected on Friday Delivers next Monday
it ('Should Deliver next Monday if collected Friday', async () => {
let ShipDate = '22-11-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('ND09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('25-11-2019')
})
// Test ND collected on Friday before BH, Delivers next Tuesday
it ('Should deliver next Tuesday if collected on Friday before Bank Holiday Monday', async () => {
let ShipDate = '23-08-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('ND09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('27-08-2019')
})
// Test ND collected on Thursday before Easter, Delivers next Tuesday
it ('Should deliver next Tuesday if collected on Thursday before Easter Weekend', async () => {
let ShipDate = '18-04-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('ND09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('23-04-2019')
})
// Christmas test (Collect on Christmas Eve, but won't deliver to 27th)
it ('Should deliver day after boxing day if collected on Christmas Eve', async () => {
let ShipDate = '24-12-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('ND09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('27-12-2019')
})
})
/**
* Test 2-5 day services
*/
describe ('Test 2-5 Day (Any other service) Behaviour', async () => {
it ('Should should deliver on the next Monday if picked up on the Monday before', async () => {
let ShipDate = '25-11-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('TDLP', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('02-12-2019')
})
// Test for POST (2nd Class Mail service)
})
/**
* Test saturday services
*/
describe ('Test NS/CS (Saturday Parcel) Behaviour', async () => {
// Test NS/CS collected on Friday, Delivers Saturday
it ('Should deliver on Saturday if collected on Friday', async () => {
let ShipDate = '29-11-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('NS09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('30-11-2019')
})
// Test NC/CS collected on Monday, Delivers Saturday
it ('Should deliver on Saturday if collected on Monday', async () => {
let ShipDate = '25-11-2019'
let DeliveryDate = await Services.CalculateDeliveryDateTime('NS09', Moment(ShipDate, 'DD-MM-YYYY'))
chai.expect(DeliveryDate.format('DD-MM-YYYY')).to.equal('30-11-2019')
})
// Test for SQ10 (Saturday Limited Quantity)
// Test for SL10 (Saturday Lightweight)
// Test for SN10 (Saturdy Non-Conveyable)
// What happens if the Saturday to be delivered on is a Bank Holiday (Or is this too edgy?)
})
// Question - Does NS (Saturday Service) have time slots - YES
// But only 9, 10, 12
// If Service.Weekday is false and Service.Saturday, then Saturday
// Don't deliver on Sundays, ever.
// TODO: Are there any services that offer both weekday and saturday services?
// TODO: How accurate is the data we fetch from the Services table in continuus?
// TODO: Services file needs updating for instances where Saturday is also a holiday (this will happen at some point in the future)
// TODO: When saturday delivery, but the saturday is a bank holiday - ARGHHH