Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update script for testing demo #2235

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ module.exports = {
plugins: ['@typescript-eslint', 'prettier', 'import'],
// add your custom rules here
rules: {
'import/order': ['error', {
groups: [
'builtin', // Built-in types are first
'external', // Then the index file
'internal',
]
}],
// 非开发模式禁用debugger
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
// 允许调用首字母大写的函数时没有 new 操作符
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cover": "jest --coverage",
"test": "jest && jest -c jest.e2e.config.js",
"test:snap-update": "npm run test:unit -- -u",
"test:demo": "node gen-demo-test.js",
"test:demo": "node script/gen-demo-test.js",
"test:unit": "jest",
"test:e2e": "jest -c jest.e2e.config.js",
"badge": "node script/coverage-badge.js",
Expand Down
8 changes: 4 additions & 4 deletions gen-demo-test.js → script/gen-demo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const upperFirst = require('lodash/upperFirst');
// };

const CONFIG = {
sourcePath: path.resolve(__dirname, 'src'),
targetPath: path.resolve(__dirname, 'src'),
defaultTemplate: ['import simulate from \'miniprogram-simulate\';', 'import path from \'path\';'].join('\n'),
sourcePath: path.resolve(__dirname, '../src'),
targetPath: path.resolve(__dirname, '../src'),
defaultTemplate: ["import path from 'path';", "import simulate from 'miniprogram-simulate';"].join('\n'),
};

/*
Expand Down Expand Up @@ -115,7 +115,7 @@ function main() {
outputOneComponentTestFile(componentFolder, demoFiles);
}
});
}
};
files.forEach(generation);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/action-sheet/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['align', 'grid', 'list', 'status'];

Expand Down
2 changes: 1 addition & 1 deletion src/action-sheet/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';
import * as Util from '../../common/utils';
import { show, close } from '../show';

Expand Down
2 changes: 1 addition & 1 deletion src/avatar/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['action', 'badge-avatar', 'character-avatar', 'exhibition', 'icon-avatar', 'image-avatar', 'size'];

Expand Down
2 changes: 1 addition & 1 deletion src/avatar/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('Avatar & Avatar Groups', () => {
const id = load(path.resolve(__dirname, './index'));
Expand Down
2 changes: 1 addition & 1 deletion src/back-top/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'half-round'];

Expand Down
2 changes: 1 addition & 1 deletion src/back-top/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('back-top', () => {
// 加载 back-top 组件
Expand Down
2 changes: 1 addition & 1 deletion src/badge/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'size', 'theme'];

Expand Down
2 changes: 1 addition & 1 deletion src/badge/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';
import { hex2Rgb } from '../../../test/utils/colors';

const shapes = ['circle', 'square', 'round', 'ribbon'];
Expand Down
2 changes: 1 addition & 1 deletion src/button/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'block-btn', 'disabled', 'ghost-btn', 'group-btn', 'icon-btn', 'shape', 'size', 'theme'];

Expand Down
2 changes: 1 addition & 1 deletion src/button/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('button', () => {
const button = load(path.resolve(__dirname, '../button'));
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'custom-button', 'custom-range', 'custom-text', 'multiple', 'range', 'without-popup'];

Expand Down
2 changes: 1 addition & 1 deletion src/calendar/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('calendar', () => {
const calendar = load(path.resolve(__dirname, `../calendar`), 't-calendar');
Expand Down
2 changes: 1 addition & 1 deletion src/cascader/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'keys', 'theme-tab', 'with-title', 'with-value'];

Expand Down
2 changes: 1 addition & 1 deletion src/cascader/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('cascader', () => {
const cascader = load(path.resolve(__dirname, `../cascader`));
Expand Down
2 changes: 1 addition & 1 deletion src/cell/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'multiple', 'theme'];

Expand Down
2 changes: 1 addition & 1 deletion src/cell/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('cell', () => {
const cell = load(path.resolve(__dirname, `../cell`));
Expand Down
2 changes: 1 addition & 1 deletion src/checkbox/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['all', 'base', 'card', 'horizontal', 'right', 'special', 'status', 'type'];

Expand Down
2 changes: 1 addition & 1 deletion src/checkbox/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('Checkbox', () => {
const id = load(path.resolve(__dirname, './index'));
Expand Down
77 changes: 77 additions & 0 deletions src/col/__test__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Col Col base demo works fine 1`] = `
<base>
<t-row>
<t-col
span="8"
tClass="dark"
>
col-8
</t-col>
<t-col
span="8"
tClass="light"
>
col-8
</t-col>
<t-col
span="8"
tClass="dark"
>
col-8
</t-col>
</t-row>
<t-row>
<t-col
span="4"
tClass="dark"
>
col-4
</t-col>
<t-col
offset="4"
span="16"
tClass="light"
>
col-16 col-offset-4
</t-col>
</t-row>
<t-row>
<t-col
offset="12"
span="12"
tClass="dark"
>
col-12 col-offset-12
</t-col>
</t-row>
</base>
`;

exports[`Col Col offset demo works fine 1`] = `
<offset>
<t-row
gutter="16"
>
<t-col
span="8"
tClass="dark"
>
col-8
</t-col>
<t-col
span="8"
tClass="light"
>
col-8
</t-col>
<t-col
span="8"
tClass="dark"
>
col-8
</t-col>
</t-row>
</offset>
`;
19 changes: 19 additions & 0 deletions src/col/__test__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'offset'];

describe('Col', () => {
mapper.forEach((demoName) => {
it(`Col ${demoName} demo works fine`, () => {
const id = load(path.resolve(__dirname, `../../col/_example/${demoName}/index`), demoName);
const container = simulate.render(id);
container.attach(document.createElement('parent-wrapper'));
expect(container.toJSON()).toMatchSnapshot();
});
});
});
2 changes: 1 addition & 1 deletion src/collapse/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['accordion', 'action', 'base', 'placement', 'theme'];

Expand Down
2 changes: 1 addition & 1 deletion src/collapse/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('collapse', () => {
const id = load(path.resolve(__dirname, `./index`));
Expand Down
2 changes: 1 addition & 1 deletion src/count-down/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'size'];

Expand Down
2 changes: 1 addition & 1 deletion src/count-down/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('countdown', () => {
const countdown = load(path.resolve(__dirname, `../count-down`), 't-count-down');
Expand Down
2 changes: 1 addition & 1 deletion src/date-time-picker/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['date-all', 'steps', 'time', 'year-month', 'year-month-date'];

Expand Down
2 changes: 1 addition & 1 deletion src/date-time-picker/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

describe('date-time-picker', () => {
const id = load(path.resolve(__dirname, `./index`));
Expand Down
2 changes: 1 addition & 1 deletion src/date-time-picker/date-time-picker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from 'dayjs';
import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs';
import config from '../common/config';
import { SuperComponent, wxComponent } from '../common/src/index';
import defaultLocale from './locale/zh';
Expand Down
2 changes: 1 addition & 1 deletion src/dialog/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'button', 'command', 'confirm', 'status', 'with-image', 'with-input'];

Expand Down
2 changes: 1 addition & 1 deletion src/dialog/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';
import Dialog from '../index';
import * as Util from '../../common/utils';

Expand Down
2 changes: 1 addition & 1 deletion src/divider/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'theme'];

Expand Down
2 changes: 1 addition & 1 deletion src/divider/__test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

// 文本位置
const textAlign = ['left', 'center', 'right'];
Expand Down
2 changes: 1 addition & 1 deletion src/drawer/__test__/demo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* 该文件为由脚本 `npm run test:demo` 自动生成,如需修改,执行脚本命令即可。请勿手写直接修改,否则会被覆盖
*/

import simulate from 'miniprogram-simulate';
import path from 'path';
import simulate from 'miniprogram-simulate';

const mapper = ['base', 'footer', 'icon-drawer', 'title'];

Expand Down
Loading
Loading