Skip to content

Commit

Permalink
basic test generate default value
Browse files Browse the repository at this point in the history
  • Loading branch information
roma219 committed Oct 10, 2019
1 parent e995ca3 commit ae4f738
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 20 additions & 0 deletions src/utils/__tests__/generateDefaultValue.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { generateDefaultValue } from '../generateDefaultValue'
import { ISchema } from '@/types'

import config from '@/utils/config'

describe('generateDefaultValue utility function', () => {
it('type=string is TextInput', () => {

const value = generateDefaultValue({
type: 'object',
properties: {
a: { type: 'string', default: 'aaa', componentName: '', eventName: '' },
b: { type: 'number', default: 123, componentName: '', eventName: '' }
},
componentName: '', eventName: ''
} as ISchema)

expect(value).toEqual({ a: 'aaa', b: 123 })
})
})
1 change: 1 addition & 0 deletions src/utils/generateDefaultValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ISchema } from '@/types'
import { JSONSchema7 } from 'json-schema'

export const generateDefaultValue = (schema: ISchema) : { [key: string]: any } => {
let defaultValue = schema.default
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/example.spec.ts

This file was deleted.

0 comments on commit ae4f738

Please sign in to comment.