Skip to content

Commit

Permalink
fix: 修复单测 (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue authored Jan 5, 2023
1 parent 82291ec commit eb58f5a
Show file tree
Hide file tree
Showing 294 changed files with 278 additions and 2,334 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/ci-16.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: CI
name: CI-16

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/ci-18.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This is a basic workflow to help you get started with Actions

name: CI-18

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "ci"
ci:
# The type of runner that the job will run on
runs-on: macos-latest

strategy:
matrix:
node_version: ['18']

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: install
run: |
yarn install
- name: lint
run: |
npm run lint
env:
CI: true

- name: build
run: |
npm run build
env:
CI: true

- name: test
run: |
npm run test
env:
CI: true

- name: save diff snapshot
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: diff snapshot
path: |
packages/**/__image_snapshots__/__diff_output__/*.png
!**/node_modules/**
10 changes: 2 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ module.exports = {
testEnvironment: 'jest-electron/environment',
preset: 'ts-jest/presets/js-with-ts',
collectCoverage: false,
collectCoverageFrom: [
'packages/*/src/**/*.{ts,tsx,js}',
'!packages/my/src/**/*.{ts,tsx,js}',
'!packages/wx/src/**/*.{ts,tsx,js}',
'!packages/site/src/**/*.{ts,tsx,js}',
'!**/node_modules/**',
],
collectCoverageFrom: ['packages/*/src/**/*.{ts,tsx,js}', '!**/node_modules/**'],
modulePathIgnorePatterns: ['packages/*/dist'],
testPathIgnorePatterns: [],
testRegex: '/test/.*\\.test\\.tsx?$',
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
transformIgnorePatterns: ['<rootDir>/node_modules/(?!@mapbox)'],
testTimeout: 10000,
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/jest-image-snapshot": "^4.3.1",
"@types/jest-image-snapshot": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"canvas-to-buffer": "^1.1.1",
Expand All @@ -75,7 +75,7 @@
"generate-changelog": "^1.8.0",
"jest": "^26.6.3",
"jest-electron": "^0.1.12",
"jest-image-snapshot": "^4.5.1",
"jest-image-snapshot": "^6.1.0",
"lerna": "^3.22.1",
"limit-size": "^0.1.4",
"pre-commit": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const { props } = (
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();
```

## Development
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const { props } = (
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();
```

更多示例:[demos](https://f2.antv.vision/zh/examples)
Expand Down
17 changes: 8 additions & 9 deletions packages/f2/src/components/zoom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class Zoom<P extends ZoomProps = ZoomProps, S extends ZoomState = ZoomState> ext
const { width: coordWidth } = coord;

const ratio = (deltaX / coordWidth) * panSensitive;

const newRange = this._doPan(ratio, 'x');
return newRange;
}
Expand Down Expand Up @@ -490,39 +489,39 @@ class Zoom<P extends ZoomProps = ZoomProps, S extends ZoomState = ZoomState> ext

_clearEvents() {
const { context, props, scale } = this;
const { canvas } = context;
const { gesture } = context;
const { onPinchEnd, onPanEnd, onPinchStart, pan, pinch, onPan, onPinch, swipe } = props;
// 统一解绑事件
if (pan !== false) {
canvas.off('panstart', () => {
gesture.off('panstart', () => {
this.onStart();
onPinchStart();
});
canvas.off('pan', (ev) => {
gesture.off('pan', (ev) => {
this.onPan(ev);
onPan(ev);
});
canvas.off('panend', () => {
gesture.off('panend', () => {
this.onEnd();
onPanEnd({ scale });
});
}
if (pinch !== false) {
canvas.off('pinchstart', () => {
gesture.off('pinchstart', () => {
this.onStart();
onPinchStart();
});
canvas.off('pinch', (ev) => {
gesture.off('pinch', (ev) => {
this.onPinch(ev);
onPinch(ev);
});
canvas.off('pinchend', () => {
gesture.off('pinchend', () => {
this.onEnd();
onPinchEnd({ scale });
});
}
if (swipe !== false) {
canvas.off('swipe', this.onSwipe);
gesture.off('swipe', this.onSwipe);
}
}
}
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/f2/test/base/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('base/component', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(50);

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions packages/f2/test/canvas/graphic.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(100);
expect(context).toMatchImageSnapshot();
Expand All @@ -98,7 +98,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(100);
expect(context).toMatchImageSnapshot();
Expand All @@ -113,7 +113,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(100);
expect(context).toMatchImageSnapshot();
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(100);
expect(context).toMatchImageSnapshot();
Expand All @@ -214,7 +214,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(500);
expect(context).toMatchImageSnapshot();
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(500);
expect(context).toMatchImageSnapshot();
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(500);
expect(context).toMatchImageSnapshot();
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('Canvas', () => {
);

const canvas = new Canvas(props);
canvas.render();
await canvas.render();

await delay(100);
expect(context).toMatchImageSnapshot();
Expand Down
Loading

0 comments on commit eb58f5a

Please sign in to comment.