feat(data-loading): load fee schedule catalogs and data from generated JSON payloads instead of bundled Germany TypeScript exports
This commit is contained in:
@@ -1,21 +1,31 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as feeSchedules from '../ts/index.js';
|
||||
|
||||
const getGermanyCatalog = () => {
|
||||
const catalog = feeSchedules.FEE_SCHEDULE_CATALOGS.find((item) => item.countryCode === 'DE');
|
||||
if (!catalog) {
|
||||
throw new Error('Expected Germany catalog in generated fee schedule payload.');
|
||||
}
|
||||
|
||||
return catalog;
|
||||
};
|
||||
|
||||
tap.test('exports Germany fee schedules and API helpers', async () => {
|
||||
expect(feeSchedules.GERMANY_FEE_SCHEDULES).toBeArray();
|
||||
expect(feeSchedules.GERMANY_FEE_SCHEDULE_DATA).toBeArray();
|
||||
expect(feeSchedules.GERMANY_GOAE_FEE_SCHEDULE_DATA.scheduleId).toEqual('de-goae');
|
||||
expect(feeSchedules.GERMANY_FEE_SCHEDULE_CATALOG.countryCode).toEqual('DE');
|
||||
expect(feeSchedules.FEE_SCHEDULE_CATALOGS).toBeArray();
|
||||
expect(feeSchedules.FEE_SCHEDULE_DATA).toBeArray();
|
||||
expect(feeSchedules.SUPPORTED_COUNTRY_CODES).toContain('DE');
|
||||
expect(feeSchedules.FEE_SCHEDULE_CATALOGS).toHaveLength(1);
|
||||
expect(feeSchedules.FeeSchedules).toBeTypeOf('function');
|
||||
expect(feeSchedules.feeSchedules).toBeInstanceOf(feeSchedules.FeeSchedules);
|
||||
});
|
||||
|
||||
tap.test('contains the initial German schedule catalog', async () => {
|
||||
expect(feeSchedules.GERMANY_FEE_SCHEDULES).toHaveLength(21);
|
||||
expect(feeSchedules.GERMANY_FEE_SCHEDULE_DATA).toHaveLength(21);
|
||||
const germanyCatalog = getGermanyCatalog();
|
||||
|
||||
for (const schedule of feeSchedules.GERMANY_FEE_SCHEDULES) {
|
||||
expect(germanyCatalog.schedules).toHaveLength(21);
|
||||
expect(feeSchedules.FEE_SCHEDULE_DATA).toHaveLength(21);
|
||||
|
||||
for (const schedule of germanyCatalog.schedules) {
|
||||
expect(schedule.id).toBeTypeofString();
|
||||
expect(schedule.countryCode).toEqual('DE');
|
||||
expect(schedule.area).toBeTypeofString();
|
||||
Reference in New Issue
Block a user