Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
schedule test
Browse files Browse the repository at this point in the history
  • Loading branch information
joeb000 committed Jun 29, 2020
1 parent 982ad44 commit 2c3ef19
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/ap.js/__tests__/apis/Utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import Deployments from '@atpar/ap-contracts/deployments.json';
import { Utils, Contracts } from '../../src/apis';

import DEFAULT_TERMS from '../Default-Terms.json';
import DEFAULT_TERMS_SCHEDULE from '../default-terms-schedule.json';
import { Terms, isPAMTerms, isANNTerms, isCERTFTerms, isCECTerms, isCEGTerms } from '../../src/types';
import { removeNullEvents } from '../../src/utils/Schedule';


describe('Utils', (): void => {
Expand All @@ -24,16 +26,25 @@ describe('Utils', (): void => {
});

describe('Schedule', (): void => {


it('should remove null events', async (): Promise<void> => {
const schedule = [
'0x0200000000000000000000000000000000000000000000000000000050e22700',
'0x1400000000000000000000000000000000000000000000000000000052c35a80',
'0x0000000000000000000000000000000000000000000000000000000000000000'
];
const newSchedule = removeNullEvents(schedule);
expect(newSchedule.length).toBe(2)
});

it('should return schedule for PAM terms', async (): Promise<void> => {
const terms: Terms = DEFAULT_TERMS;
const pamTerms = Utils.conversion.extractPAMTerms(terms);
const schedule = await Utils.schedule.computeScheduleFromTerms(contracts.engine(pamTerms.contractType), pamTerms);

expect(schedule.length).toBeGreaterThan(0);
expect(schedule).toEqual(DEFAULT_TERMS_SCHEDULE)
});

});

describe('Conversion', (): void => {
Expand Down
17 changes: 17 additions & 0 deletions packages/ap.js/__tests__/default-terms-schedule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
"0x0200000000000000000000000000000000000000000000000000000050e22700",
"0x0900000000000000000000000000000000000000000000000000000050e22700",
"0x09000000000000000000000000000000000000000000000000000000510b0580",
"0x09000000000000000000000000000000000000000000000000000000512fef80",
"0x090000000000000000000000000000000000000000000000000000005158ce00",
"0x0900000000000000000000000000000000000000000000000000000051805b00",
"0x0900000000000000000000000000000000000000000000000000000051a93980",
"0x0900000000000000000000000000000000000000000000000000000051d0c680",
"0x0900000000000000000000000000000000000000000000000000000051f9a500",
"0x0900000000000000000000000000000000000000000000000000000052228380",
"0x09000000000000000000000000000000000000000000000000000000524a1080",
"0x090000000000000000000000000000000000000000000000000000005272ef00",
"0x09000000000000000000000000000000000000000000000000000000529a7c00",
"0x0900000000000000000000000000000000000000000000000000000052c35a80",
"0x1400000000000000000000000000000000000000000000000000000052c35a80"
]

0 comments on commit 2c3ef19

Please sign in to comment.