Skip to content

Commit e10b50c

Browse files
committed
Merge branch 'master' into complex-table
2 parents 2b134f8 + 24d0a91 commit e10b50c

25 files changed

+872
-74
lines changed

.eslintrc.js

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
1-
/* eslint-env node */
21
module.exports = {
32
root: true,
4-
ignorePatterns: ['*.config.js', '*.spec.js', 'dist/*'],
3+
4+
// Ignore every file but the patterns specified after '/*'
5+
ignorePatterns: [
6+
'/*',
7+
'!/components', // all files inside /components
8+
'!/tools', // all files inside /tools
9+
'!/*.js', // all JS files in root dir
10+
],
11+
512
extends: [
613
'plugin:vue/vue3-recommended',
714
'eslint:recommended',
815
'plugin:storybook/recommended',
916
],
1017

1118
plugins: ['vue'],
12-
13-
env: {
14-
'vue/setup-compiler-macros': true,
15-
},
19+
parser: 'vue-eslint-parser',
1620

1721
rules: {
1822
'vue/multi-word-component-names': 'off',
1923
},
24+
25+
overrides: [
26+
// Config for unit tests
27+
{
28+
files: ['*.spec.js'],
29+
plugins: ['jest'],
30+
extends: [
31+
'plugin:jest/recommended',
32+
'plugin:jest-formatting/strict',
33+
],
34+
env: {
35+
jest: true,
36+
'jest/globals': true,
37+
},
38+
globals: {
39+
global: 'writable',
40+
},
41+
},
42+
43+
// Config for files that run in node env (config files, etc)
44+
{
45+
files: ['*.config.js', '.eslintrc.js'],
46+
env: {
47+
node: true,
48+
},
49+
},
50+
],
2051
};

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const path = require('path');
1+
const path = require('node:path');
22

33

44
module.exports = {

components/jest.config.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** @type {import('jest').Config} */
12
module.exports = {
23
rootDir: __dirname,
4+
displayName: 'components',
5+
36
moduleFileExtensions: [
47
'js',
58
'json',
@@ -26,17 +29,13 @@ module.exports = {
2629

2730
clearMocks: true,
2831

29-
testMatch: [
30-
'<rootDir>/(**/*\\.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))',
31-
],
32-
33-
collectCoverage: true,
34-
3532
collectCoverageFrom: [
36-
'src/**/*.{js,vue}',
33+
'<rootDir>/src/**/*.{js,vue}',
3734
],
3835

39-
coverageDirectory: '<rootDir>/test/coverage/',
36+
testMatch: [
37+
'<rootDir>/(**/*\\.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))',
38+
],
4039

4140
testEnvironment: 'jsdom',
4241
testEnvironmentOptions: {

components/src/core/helpers.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ describe('clone', () => {
1818
});
1919

2020
describe('has', () => {
21-
it('should check if object has an own property of key', () => {
21+
it('returns true if the object has the property', () => {
2222
expect(has('prop', { prop: undefined })).toBeTruthy();
2323
});
2424

25-
it('should check if object has an own property of key', () => {
25+
it('returns false if the object does not have the property', () => {
2626
expect(has('prop1', { prop: undefined })).toBeFalsy();
2727
});
2828
});

components/src/core/injector/core/launcher.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,39 @@ describe('$init', () => {
4444

4545
it('handler should set proper id to state', () => {
4646
handler({}, { $id: 'XXX' });
47+
4748
expect(core.id).toBe('XXX');
4849
});
4950

5051
it('should handler should set passed data to state', () => {
5152
handler({ foo: 'BAR' }, {});
53+
5254
expect(core.state).toEqual({ foo: 'BAR' });
5355
});
5456

5557
it('should emit "$size" event', () => {
5658
handler({}, {});
59+
5760
expect(injector.emit.mock.calls[2]).toEqual(['$size', 'SIZE']);
5861
});
5962

6063
it('should get sizes from $size method', () => {
6164
handler({}, {});
65+
6266
expect(core.size).toHaveBeenCalled();
6367
});
6468

6569
it('should set interval', () => {
6670
handler({}, {});
71+
6772
expect(setInterval).toHaveBeenCalledWith(expect.any(Function), 300);
6873
});
6974

7075
it('should set interval for sizing', () => {
7176
handler({}, {});
7277
injector.emit.mock.calls = [];
7378
setInterval.mock.calls[0][0]();
79+
7480
expect(injector.emit).toHaveBeenCalledWith('$size', 'SIZE');
7581
});
7682
});

components/src/core/injector/index.spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ describe('createInjector on launcher error', () => {
4242
launcher.mockImplementation(() => Promise.reject(new Error('ERROR')));
4343
});
4444

45-
it('should throw an error', () => {
46-
expect(createInjector()).rejects.toThrow('ERROR');
45+
it('should throw an error', async () => {
46+
let error;
47+
48+
try {
49+
await createInjector();
50+
} catch (e) {
51+
error = e;
52+
}
53+
54+
expect(error).toBeInstanceOf(Error);
55+
expect(error.message).toEqual('ERROR');
4756
});
4857
});

components/src/index.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable vue/one-component-per-file */
12
import createApp from './index';
23
import injector from '~core/injector';
34
import registerWidget from '~core/registerWidget';

components/src/widgets/button/widget.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ describe('Button widget', () => {
1515
expect(result).toEqual(`
1616
background-color: #2C98F0;
1717
color: #FFF;
18+
height: auto;
19+
width: auto;
1820
`);
1921
});
2022
});

components/src/widgets/icon/widget.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Icon', () => {
5959
expect(result).toEqual('12px');
6060
});
6161

62-
it('shouldn\`t add px if size prop is passed as String with "px"', () => {
62+
it('shouldn\'t add px if size prop is passed as String with "px"', () => {
6363
const component = Icon.setup(
6464
{size: '12px'},
6565
{expose: () => 'mock reqired for composition api'}

components/src/widgets/icon/widget.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import * as icons from '@cloudblueconnect/material-svg';
1313
defineOptions({
1414
name: 'Icon',
15-
})
15+
});
1616
const props = defineProps({
1717
iconName: {
1818
type: String,
@@ -26,7 +26,7 @@
2626
type: [Number, String],
2727
default: '24',
2828
}
29-
})
29+
});
3030
const addUnits = (value) => {
3131
const regex = /^-?\d+$/;
3232
if (!regex.test(value)) return value;
@@ -39,7 +39,7 @@
3939
width: addUnits(props.size),
4040
}
4141
})
42-
42+
4343
const icon = computed(() => {
4444
return icons[props.iconName];
4545
})

0 commit comments

Comments
 (0)