test: add web test and group panel helper

pull/81/head
moonrailgun 3 years ago
parent 082a6bf611
commit b15d610249

@ -9,19 +9,19 @@ module.exports = {
moduleNameMapper: {
'\\.(css|less|scss)$': 'identity-obj-proxy',
...pathsToModuleNameMapper(webCompilerOptions.paths, {
prefix: '<rootDir>/web/',
prefix: '<rootDir>/',
}),
},
// projects: ['<rootDir>/web/'], // https://jestjs.io/docs/configuration#projects-arraystring--projectconfig
rootDir: '../',
rootDir: '.',
testRegex: '.*\\.(test|spec)\\.tsx?$',
testPathIgnorePatterns: ['/node_modules/', '/e2e/cypress/'],
transform: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/test/fileTransformer.js',
'<rootDir>/../test/fileTransformer.js',
},
transformIgnorePatterns: ['/node_modules/'],
setupFiles: ['<rootDir>/test/setup.js'],
setupFiles: ['<rootDir>/../test/setup.js'],
setupFilesAfterEnv: [],
globals: {
window: {},

@ -1,10 +1,46 @@
import { buildDataFromValues } from '../helper';
jest.mock('@/plugin/common', () => ({
pluginGroupPanel: [
{
name: 'fooPluginPanel',
label: 'fooPluginPanelLabel',
provider: 'foo',
},
],
}));
describe('buildDataFromValues', () => {
test.each([
[
{ name: 'name', type: 'type' },
{ name: 'name', type: 'type' },
{ name: 'name', type: 0 },
{
name: 'name',
type: 0,
pluginPanelName: undefined,
provider: undefined,
meta: {},
},
],
[
{ name: 'name', type: 1 },
{
name: 'name',
type: 1,
pluginPanelName: undefined,
provider: undefined,
meta: {},
},
],
[
{ name: 'name', type: 'fooPluginPanel' },
{
name: 'name',
type: 2,
pluginPanelName: 'fooPluginPanel',
provider: 'foo',
meta: {},
},
],
])('%o', (input, output) => {
expect(buildDataFromValues(input)).toEqual(output);

Loading…
Cancel
Save