Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Mar 25, 2024
1 parent e2e5b69 commit 4c5ff59
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/process/normalize/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
import { expect } from 'chai';

import { TimeComponent } from 'types';
import { TimeComponent, SelectBoxesComponent } from 'types';
import { normalizeProcessSync } from '../';
import { generateProcessorContext } from '../../__tests__/fixtures/util';

const timeField: TimeComponent = {
type: 'time',
key: 'time',
label: 'Time',
input: true,
dataFormat: 'HH:mm:ss'
};

it('Should normalize a time component with a valid time value that doees not match dataFormat', async () => {
const timeField: TimeComponent = {
type: 'time',
key: 'time',
label: 'Time',
input: true,
dataFormat: 'HH:mm:ss'
};
const data = { time: '12:00' };
const context = generateProcessorContext(timeField, data);
normalizeProcessSync(context);
expect(context.data).to.deep.equal({time: '12:00:00'});
});

it('Should normalize a select boxes component with an incorrect data model', () => {
const selectBoxesField: SelectBoxesComponent = {
type: 'selectboxes',
key: 'selectBoxes',
label: 'Select Boxes',
input: true,
values: [
{label: 'One', value: 'one'},
{label: 'Two', value: 'two'},
{label: 'Three', value: 'three'}
]
};
const data = {
selectBoxes: ''
};
const context = generateProcessorContext(selectBoxesField, data);
normalizeProcessSync(context);
expect(context.data).to.deep.equal({selectBoxes: {}});
});

0 comments on commit 4c5ff59

Please sign in to comment.