UNPKG

@aptpod/data-viz-create-visual-parts-react

Version:

template of npm project with typescript

96 lines (92 loc) 2 kB
import { parse, defaultExtension, Extension, BG_COLOR_BLUE } from './extension' /** * Parseのテスト */ describe('parse', () => { type TestData = { id: string args: { extension: any } exp: Extension } const testDatas: TestData[] = [ { id: 'set extension to null', args: { extension: null, }, exp: defaultExtension, }, { id: 'set extension to undefined', args: { extension: undefined, }, exp: defaultExtension, }, { id: 'set extension to number', args: { extension: 123, }, exp: defaultExtension, }, { id: 'set extension to empty object', args: { extension: {}, }, exp: defaultExtension, }, { id: 'set extension to bgColor blue', args: { extension: { bgColor: BG_COLOR_BLUE }, }, exp: { ...defaultExtension, bgColor: BG_COLOR_BLUE }, }, { id: 'set extension to all valid values', args: { extension: { description: 'description', bgColor: BG_COLOR_BLUE, factor: 1, }, }, exp: { ...defaultExtension, description: 'description', bgColor: BG_COLOR_BLUE, factor: 1, }, }, { id: 'set extension to all invalid values', args: { extension: { description: 123, bgColor: 'invalid color', factor: 'invalid factor', }, }, exp: defaultExtension, }, { id: 'set extension to additional property', args: { extension: { description: 'test description', additionalProperty: 'additionalProperty', }, }, exp: { ...defaultExtension, description: 'test description' }, }, ] testDatas.forEach(({ id, args: { extension }, exp }) => { test(id, () => { expect(parse(extension)).toStrictEqual(exp) }) }) })