-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix schema generation & add Vue2 typings and tests
- Loading branch information
Showing
23 changed files
with
1,158 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const devPresets = ['@vue/babel-preset-app']; | ||
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript']; | ||
const devPresets = ['@vue/cli-plugin-babel/preset']; | ||
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript', ]; | ||
module.exports = { | ||
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets) | ||
presets: (process.env.NODE_ENV === 'production' ? buildPresets: devPresets) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
import { PropType } from "vue"; | ||
|
||
/** | ||
* Switch between Vue 3 and Vue 2 '@vue/composition-api'. | ||
*/ | ||
export { computed, defineComponent, inject, ref, watch, watchEffect } from "vue"; | ||
|
||
/** | ||
* Compatibility type as defineComponent of '@vue/composition-api' can't properly handle PropTypes. | ||
*/ | ||
export type CompType<S,_V> = PropType<S> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel', | ||
transform: { | ||
'^.+\\.vue$': 'vue-jest' | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const bindings = <B> (b:B) : B => b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { JsonFormsUISchemaRegistryEntry } from '@jsonforms/core'; | ||
import { shallowMount } from '@vue/test-utils'; | ||
import { JsonForms } from '../../src'; | ||
import { Generate } from '@jsonforms/core'; | ||
import { bindings } from '../testHelper'; | ||
|
||
describe('JsonForms.vue', () => { | ||
it('uses undefined as schema prop when not given', () => { | ||
const data = { number: 5 }; | ||
const renderers: JsonFormsUISchemaRegistryEntry[] = []; | ||
const wrapper = shallowMount(JsonForms, bindings({ | ||
props: { data, renderers } | ||
})); | ||
expect(wrapper.props('schema')).toBe(undefined); | ||
}); | ||
|
||
it('generates schema when not given via prop', () => { | ||
const data = { number: 5.5 }; | ||
const renderers: JsonFormsUISchemaRegistryEntry[] = []; | ||
const wrapper = shallowMount(JsonForms, bindings({ | ||
props: { data, renderers } | ||
})); | ||
console.log(Generate.jsonSchema(data)); | ||
console.log((wrapper.vm as any).jsonforms.core.schema); | ||
expect((wrapper.vm as any).jsonforms.core.schema).toEqual(Generate.jsonSchema(data)); | ||
}); | ||
|
||
it('generates ui schema when not given via prop', () => { | ||
const data = { number: 5.5 }; | ||
const schema = { | ||
type: 'object', | ||
properties: { number: { type: 'number' } } | ||
}; | ||
const renderers: JsonFormsUISchemaRegistryEntry[] = []; | ||
const wrapper = shallowMount(JsonForms, bindings({ | ||
props: { data, schema, renderers } | ||
})); | ||
expect((wrapper.vm as any).jsonforms.core.uischema).toEqual( | ||
Generate.uiSchema(schema) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/ | ||
dev/* | ||
!dev/serve.ts | ||
tests/unit/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const devPresets = ['@vue/babel-preset-app']; | ||
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript']; | ||
const devPresets = ['@vue/cli-plugin-babel/preset']; | ||
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript', ]; | ||
module.exports = { | ||
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets) | ||
presets: (process.env.NODE_ENV === 'production' ? buildPresets: devPresets) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
/** | ||
* Switch between Vue 3 and Vue 2 '@vue/composition-api'. | ||
*/ | ||
export { computed, defineComponent, inject, ref, watch, watchEffect } from "@vue/composition-api"; | ||
|
||
/** | ||
* Compatibility type as defineComponent of '@vue/composition-api' can't properly handle PropTypes. | ||
*/ | ||
export type CompType<_S,V> = V; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel", | ||
}; |
Oops, something went wrong.