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

test codecov #248

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 6 additions & 9 deletions .umirc.ts → .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
import { defineConfig } from 'dumi';

export default defineConfig({
title: 'rc-virtual-list',
favicon:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
logo:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
themeConfig: {
name: 'virtual-list',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
outputPath: '.doc',
exportStatic: {},
resolve: {
examples: ['none'],
},
styles: [
`
.markdown table {
width: auto !important;
}
`,
]
],
});
9 changes: 0 additions & 9 deletions .fatherrc.js

This file was deleted.

5 changes: 5 additions & 0 deletions .fatherrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from 'father';

export default defineConfig({
plugins: ['@rc-component/father-plugin'],
});
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '18'

- name: cache package-lock.json
uses: actions/cache@v2
Expand All @@ -24,7 +24,7 @@ jobs:
key: lock-${{ github.sha }}

- name: create package-lock.json
run: npm i --package-lock-only
run: npm i --package-lock-only --ignore-scripts

- name: hack for singe file
run: |
Expand Down
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.storybook
.doc
node_modules
coverage/
Expand All @@ -9,8 +8,8 @@ yarn.lock
package-lock.json
!tests/__mocks__/rc-util/lib

# umi
.umi
.umi-production
.umi-test
.env.local
# dumi
.dumi/tmp
.dumi/tmp-test
.dumi/tmp-production
.env.local
9 changes: 7 additions & 2 deletions docs/demo/animate.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## animate
---
title: animate
nav:
title: Demo
path: /demo
---

<code src="../../examples/animate.tsx">
<code src="../../examples/animate.tsx"></code>
9 changes: 7 additions & 2 deletions docs/demo/basic.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## basic
---
title: basic
nav:
title: Demo
path: /demo
---

<code src="../../examples/basic.tsx">
<code src="../../examples/basic.tsx"></code>
9 changes: 7 additions & 2 deletions docs/demo/height.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## height
---
title: height
nav:
title: Demo
path: /demo
---

<code src="../../examples/height.tsx">
<code src="../../examples/height.tsx"></code>
9 changes: 7 additions & 2 deletions docs/demo/horizontal-scroll.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## horizontal scroll
---
title: horizontal-scroll
nav:
title: Demo
path: /demo
---

<code src="../../examples/horizontal-scroll.tsx">
<code src="../../examples/horizontal-scroll.tsx"></code>
9 changes: 7 additions & 2 deletions docs/demo/no-virtual.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## no-virtual
---
title: no-virtual
nav:
title: Demo
path: /demo
---

<code src="../../examples/no-virtual.tsx">
<code src="../../examples/no-virtual.tsx"></code>
9 changes: 7 additions & 2 deletions docs/demo/switch.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## switch
---
title: switch
nav:
title: Demo
path: /demo
---

<code src="../../examples/switch.tsx">
<code src="../../examples/switch.tsx"></code>
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: rc-virtual-list
hero:
title: rc-virtual-list
description: React Virtual List Component
---

<embed src="../README.md"></embed>
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
"start": "dumi dev",
"build": "dumi build",
"compile": "father build",
"prepare": "dumi setup",
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
"lint": "eslint src/ --ext .tsx,.ts",
"test": "father test",
"test": "rc-test",
"now-build": "npm run build"
},
"peerDependencies": {
"react": "*",
"react-dom": "*"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^12.1.5",
"@types/classnames": "^2.2.10",
Expand All @@ -50,24 +52,26 @@
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@types/warning": "^3.0.0",
"@umijs/fabric": "^3.0.0",
"cross-env": "^5.2.0",
"dumi": "^1.1.12",
"dumi": "^2.0.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.1.4",
"eslint": "^7.6.0",
"father": "^2.29.10",
"glob": "^7.1.6",
"father": "^4.0.0",
"glob": "^10.0.0",
"np": "^5.0.3",
"rc-animate": "^2.9.1",
"rc-test": "^7.0.15",
"react": "^v16.9.0-alpha.0",
"react-dom": "^v16.9.0-alpha.0",
"typescript": "^4.0.0"
"typescript": "^5.0.0"
},
"dependencies": {
"@babel/runtime": "^7.20.0",
"classnames": "^2.2.6",
"rc-resize-observer": "^1.0.0",
"rc-util": "^5.36.0"
}
}
}
9 changes: 7 additions & 2 deletions update-demo.js → script/update-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ paths.forEach(path => {
const name = path.split('/').pop().split('.')[0];
fs.writeFile(
`./docs/demo/${name}.md`,
`## ${name}
`---
title: ${name}
nav:
title: Demo
path: /demo
---

<code src="../../examples/${name}.tsx">
<code src="../../examples/${name}.tsx"></code>
`,
'utf8',
function(error) {
Expand Down
37 changes: 26 additions & 11 deletions tests/scroll.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '@testing-library/jest-dom';
import { createEvent, fireEvent, render } from '@testing-library/react';
import { mount } from 'enzyme';
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
import { resetWarned } from 'rc-util/lib/warning';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { mount } from 'enzyme';
import { spyElementPrototypes } from './utils/domHook';
import List from '../src';
import { createEvent, fireEvent, render } from '@testing-library/react';
import { resetWarned } from 'rc-util/lib/warning';
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
import '@testing-library/jest-dom';
import { spyElementPrototypes } from './utils/domHook';

function genData(count) {
return new Array(count).fill(null).map((_, index) => ({ id: String(index) }));
Expand Down Expand Up @@ -181,13 +181,20 @@ describe('List.Scroll', () => {
expect(preventDefault).toHaveBeenCalled();
});

describe('scrollbar', () => {
it('moving', () => {
const genScrollbarMovingTestFn = (direction) => {
return () => {
const listRef = React.createRef();
const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100), ref: listRef });
const wrapper = genList({
itemHeight: 20,
height: 100,
data: genData(100),
ref: listRef,
direction,
scrollWidth: 10,
});

// Mouse down
wrapper.find('.rc-virtual-list-scrollbar-thumb').simulate('mousedown', {
wrapper.find('.rc-virtual-list-scrollbar-thumb').first().simulate('mousedown', {
pageY: 0,
});

Expand All @@ -211,7 +218,11 @@ describe('List.Scroll', () => {
});

expect(wrapper.find('ul').instance().scrollTop > 10).toBeTruthy();
});
};
};

describe('scrollbar', () => {
it('moving', genScrollbarMovingTestFn());

describe('not show scrollbar when disabled virtual', () => {
[
Expand All @@ -238,6 +249,10 @@ describe('List.Scroll', () => {
});
});

describe('scrollbar rtl', () => {
it('moving', genScrollbarMovingTestFn('rtl'));
});

it('no bubble', () => {
const wrapper = genList({ itemHeight: 20, height: 100, data: genData(100) });

Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"jsx": "preserve",
"jsx": "react",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"],
"@@/*": [".dumi/tmp/*"],
"rc-virtual-list": ["src/index.ts"]
}
}
Expand Down
Loading