Skip to content

Commit

Permalink
refactor(instabox)!: rename rjp to instabox (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Feb 1, 2022
1 parent 4480425 commit da607c4
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/config/platform/platformCarrierMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as PLATFORMS from '@/data/keys/platformKeys';
export const platformCarrierMap = {
[PLATFORMS.MYPARCEL]: [
CARRIERS.POSTNL,
CARRIERS.RED_JE_PAKKETJE,
CARRIERS.INSTABOX,
CARRIERS.DHL,
],
[PLATFORMS.SENDMYPARCEL]: [
Expand Down
6 changes: 3 additions & 3 deletions src/data/carriers/carrierConfigurationFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BpostCarrierConfiguration } from '@/data/carriers/bpostCarrierConfigura
import { CheapCargoCarrierConfiguration } from '@/data/carriers/cheapCargoCarrierConfiguration';
import { DhlCarrierConfiguration } from '@/data/carriers/dhlCarrierConfiguration';
import { DpdCarrierConfiguration } from '@/data/carriers/dpdCarrierConfiguration';
import { InstaboxCarrierConfiguration } from '@/data/carriers/instaboxCarrierConfiguration';
import { PostNlCarrierConfiguration } from '@/data/carriers/postNlCarrierConfiguration';
import { RedJePakketjeCarrierConfiguration } from '@/data/carriers/redJePakketjeCarrierConfiguration';
import memoize from 'lodash-es/memoize';

const carrierConfiguration = memoize((carrierName, platform) => {
Expand All @@ -19,8 +19,8 @@ const carrierConfiguration = memoize((carrierName, platform) => {
return new DpdCarrierConfiguration(platform);
case CARRIERS.POSTNL:
return new PostNlCarrierConfiguration(platform);
case CARRIERS.RED_JE_PAKKETJE:
return new RedJePakketjeCarrierConfiguration(platform);
case CARRIERS.INSTABOX:
return new InstaboxCarrierConfiguration(platform);
default:
throw new Error(`No configuration found for carrier ${carrierName}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AbstractCarrierConfiguration } from '@/data/carriers/abstractCarrierCon
import { MYPARCEL } from '@/data/keys/platformKeys';
import { countryCodes } from '@/data/keys/countryCodes';

export class RedJePakketjeCarrierConfiguration extends AbstractCarrierConfiguration {
export class InstaboxCarrierConfiguration extends AbstractCarrierConfiguration {
getCountriesForDelivery() {
return [
countryCodes.NETHERLANDS,
Expand Down
2 changes: 1 addition & 1 deletion src/data/keys/carrierKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DPD = 'dpd';
export const BPOST = 'bpost';

/** @type {MyParcel.CarrierName} */
export const RED_JE_PAKKETJE = 'redjepakketje';
export const INSTABOX = 'instabox';

/** @type {MyParcel.CarrierName} */
export const CHEAP_CARGO = 'cheapcargo';
Expand Down
2 changes: 1 addition & 1 deletion src/sandbox/config/sandboxPlatformCarrierMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { isFeatureActive } from '@/helpers/isFeatureActive';
export const sandboxPlatformCarrierMap = {
[PLATFORMS.MYPARCEL]: [
CARRIERS.POSTNL,
...isFeatureActive('myparcel.carriers.rjp') ? [CARRIERS.RED_JE_PAKKETJE] : [],
...isFeatureActive('myparcel.carriers.rjp') ? [CARRIERS.INSTABOX] : [],
...isFeatureActive('myparcel.carriers.dhl') ? [CARRIERS.DHL] : [],
],
[PLATFORMS.SENDMYPARCEL]: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const allCarrierData = [
},
{
id: 5,
name: 'redjepakketje',
human: 'Red je Pakketje',
name: 'instabox',
human: 'Instabox',
meta: {
logo_svg: '/skin/general-images/carrier-logos/svg/redjepakketje.svg',
logo_png: '/skin/general-images/carrier-logos/redjepakketje.png',
logo_svg: '/skin/general-images/carrier-logos/svg/instabox.svg',
logo_png: '/skin/general-images/carrier-logos/instabox.png',
},
},
{
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/delivery-options/carriers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ describe('carriers', () => {
[CONFIG.KEY]: {
[CONFIG.PLATFORM]: PLATFORMS.MYPARCEL,
[CONFIG.CARRIER_SETTINGS]: {
[CARRIERS.RED_JE_PAKKETJE]: {
[CARRIERS.INSTABOX]: {
[CONFIG.ALLOW_DELIVERY_OPTIONS]: true,
},
},
},
});

await waitForEvent(UPDATED_DELIVERY_OPTIONS);
const redJePakketje = app.findChoice('carrier', CARRIERS.RED_JE_PAKKETJE);
const instabox = app.findChoice('carrier', CARRIERS.INSTABOX);
expect(app.findChoice('carrier', CARRIERS.POSTNL).exists()).toBe(false);
expect(redJePakketje.exists()).toBe(true);
expect(instabox.exists()).toBe(true);
expect(app.findChoice('carrier', CARRIERS.DHL).exists()).toBe(false);

// Single carriers don't show a carrier logo.
expect(redJePakketje.find('[data-test-id="image"]').exists()).toBe(false);
expect(instabox.find('[data-test-id="image"]').exists()).toBe(false);
});

it('can show multiple carriers', async() => {
Expand All @@ -35,7 +35,7 @@ describe('carriers', () => {
[CONFIG.KEY]: {
[CONFIG.PLATFORM]: PLATFORMS.MYPARCEL,
[CONFIG.CARRIER_SETTINGS]: {
[CARRIERS.RED_JE_PAKKETJE]: {
[CARRIERS.INSTABOX]: {
[CONFIG.ALLOW_DELIVERY_OPTIONS]: true,
},
[CARRIERS.POSTNL]: {
Expand All @@ -47,14 +47,14 @@ describe('carriers', () => {

await waitForEvent(UPDATED_DELIVERY_OPTIONS);
const postNl = app.findChoice('carrier', CARRIERS.POSTNL);
const redJePakketje = app.findChoice('carrier', CARRIERS.RED_JE_PAKKETJE);
const instabox = app.findChoice('carrier', CARRIERS.INSTABOX);
const dhl = app.findChoice('carrier', CARRIERS.DHL);

expect(postNl.exists()).toBe(true);
expect(redJePakketje.exists()).toBe(true);
expect(instabox.exists()).toBe(true);
expect(dhl.exists()).toBe(false);

expect(postNl.find('[data-test-id="image"]').exists()).toBe(true);
expect(redJePakketje.find('[data-test-id="image"]').exists()).toBe(true);
expect(instabox.find('[data-test-id="image"]').exists()).toBe(true);
});
});
2 changes: 1 addition & 1 deletion tests/unit/delivery-options/configBus.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('configBus', () => {
[CONFIG.ALLOW_SATURDAY_DELIVERY]: false,
});

expect(configBus.getSettingsByCarrier(CARRIERS.RED_JE_PAKKETJE)).toEqual(null);
expect(configBus.getSettingsByCarrier(CARRIERS.INSTABOX)).toEqual(null);
});

test('isEnabledInAnyCarrier', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/delivery-options/configurationMerger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('ConfigurationMerger', () => {
[CONFIG.PLATFORM]: MYPARCEL,
[CONFIG.DROP_OFF_DAYS]: [1, 3, 4],
[CONFIG.CARRIER_SETTINGS]: {
[CARRIERS.RED_JE_PAKKETJE]: {
[CARRIERS.INSTABOX]: {
[CONFIG.ALLOW_DELIVERY_OPTIONS]: true,
},
},
Expand All @@ -26,7 +26,7 @@ describe('ConfigurationMerger', () => {
expect(mergedConfiguration[CONFIG.KEY][CONFIG.DROP_OFF_DAYS]).toStrictEqual([1, 3, 4]);
// Check the carrier settings are overriding the defaults properly.
expect(mergedConfiguration[CONFIG.KEY][CONFIG.CARRIER_SETTINGS]).toStrictEqual({
[CARRIERS.RED_JE_PAKKETJE]: {
[CARRIERS.INSTABOX]: {
[CONFIG.ALLOW_DELIVERY_OPTIONS]: true,
[CONFIG.ALLOW_EVENING_DELIVERY]: false,
[CONFIG.ALLOW_MONDAY_DELIVERY]: false,
Expand Down
38 changes: 19 additions & 19 deletions tests/unit/delivery-options/deliveryMoment.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as CONFIG from '@/data/keys/configKeys';
import * as FORM from '@/config/formConfig';
import { BPOST, DPD, POSTNL, RED_JE_PAKKETJE } from '@/data/keys/carrierKeys';
import { BPOST, DPD, POSTNL, INSTABOX } from '@/data/keys/carrierKeys';
import { FRIDAY, MONDAY, SATURDAY, SUNDAY, THURSDAY, TUESDAY, WEDNESDAY } from '@/config/extraDeliveryConfig';
import { MYPARCEL, SENDMYPARCEL } from '@/data/keys/platformKeys';
import MockDate from 'mockdate';
Expand Down Expand Up @@ -243,24 +243,24 @@ describe('Delivery moments', () => {
});

test.each`
platform | carrier | weekday | expected
${MYPARCEL} | ${POSTNL} | ${MONDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${TUESDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${WEDNESDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${THURSDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${FRIDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${SATURDAY} | ${true}
${MYPARCEL} | ${POSTNL} | ${SUNDAY} | ${false}
${MYPARCEL} | ${RED_JE_PAKKETJE} | ${SATURDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${MONDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${TUESDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${WEDNESDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${THURSDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${FRIDAY} | ${true}
${SENDMYPARCEL} | ${BPOST} | ${SATURDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${SUNDAY} | ${false}
${SENDMYPARCEL} | ${DPD} | ${FRIDAY} | ${false}
${SENDMYPARCEL} | ${POSTNL} | ${FRIDAY} | ${false}
platform | carrier | weekday | expected
${MYPARCEL} | ${POSTNL} | ${MONDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${TUESDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${WEDNESDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${THURSDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${FRIDAY} | ${false}
${MYPARCEL} | ${POSTNL} | ${SATURDAY} | ${true}
${MYPARCEL} | ${POSTNL} | ${SUNDAY} | ${false}
${MYPARCEL} | ${INSTABOX} | ${SATURDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${MONDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${TUESDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${WEDNESDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${THURSDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${FRIDAY} | ${true}
${SENDMYPARCEL} | ${BPOST} | ${SATURDAY} | ${false}
${SENDMYPARCEL} | ${BPOST} | ${SUNDAY} | ${false}
${SENDMYPARCEL} | ${DPD} | ${FRIDAY} | ${false}
${SENDMYPARCEL} | ${POSTNL} | ${FRIDAY} | ${false}
`('handles extra dropoff day for $platform, $carrier on day $weekday correctly', ({
platform,
carrier,
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Vue } from 'vue/types/vue';
declare namespace MyParcel {
type Environment = 'dev' | 'staging' | 'acceptance' | 'prod'

type CarrierName = 'postnl' | 'bpost' | 'cheapcargo' | 'dpd' | 'redjepakketje' | 'dhl'
type CarrierName = 'postnl' | 'bpost' | 'cheapcargo' | 'dpd' | 'instabox' | 'dhl'
type CarrierID = 1 | 2 | 3 | 4 | 5 | 6
type CarrierNameOrId = CarrierName | CarrierID
type Platform = 'myparcel' | 'belgie' | 'flespakket'
Expand Down

0 comments on commit da607c4

Please sign in to comment.