Skip to content

Commit 38b931a

Browse files
committed
chore: add unit test and e2e test
1 parent 012bc7c commit 38b931a

File tree

10 files changed

+16387
-16160
lines changed

10 files changed

+16387
-16160
lines changed

.github/workflows/release.yml

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
1-
name: Release
2-
on:
3-
push:
4-
branches:
5-
- master
6-
paths:
7-
- 'src/**'
8-
9-
pull_request:
10-
branches:
11-
- master
12-
paths:
13-
- 'src/**'
14-
15-
jobs:
16-
build:
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- name: Begin CI...
21-
uses: actions/checkout@v2
22-
23-
- name: Use Node 12
24-
uses: actions/setup-node@v1
25-
with:
26-
node-version: 12.x
27-
28-
- name: Use cached node_modules
29-
uses: actions/cache@v1
30-
with:
31-
path: node_modules
32-
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
33-
restore-keys: |
34-
nodeModules-
35-
36-
- name: Install dependencies
37-
run: yarn install --frozen-lockfile
38-
env:
39-
CI: true
40-
41-
# - name: Lint
42-
# run: yarn lint
43-
# env:
44-
# CI: true
45-
46-
# - name: Test
47-
# run: yarn test --ci --coverage --maxWorkers=2
48-
# env:
49-
# CI: true
50-
51-
- name: Release
52-
run: |
53-
yarn build
54-
npm run release
55-
npm run deploy-storybook -- --ci
56-
env:
57-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
58-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- 'src/**'
8+
9+
pull_request:
10+
branches:
11+
- master
12+
paths:
13+
- 'src/**'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Begin CI...
21+
uses: actions/checkout@v2
22+
23+
- name: Use Node 12
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: 12.x
27+
28+
- name: Use cached node_modules
29+
uses: actions/cache@v1
30+
with:
31+
path: node_modules
32+
key: nodeModules-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
nodeModules-
35+
36+
- name: Install dependencies
37+
run: yarn install --frozen-lockfile
38+
env:
39+
CI: true
40+
41+
# - name: Lint
42+
# run: yarn lint
43+
# env:
44+
# CI: true
45+
46+
- name: Test
47+
run: |
48+
yarn test --ci --coverage --maxWorkers=2
49+
yarn test:e2e --ci --coverage --maxWorkers=2
50+
env:
51+
CI: true
52+
53+
- name: Release
54+
run: |
55+
yarn build
56+
npm run release
57+
npm run deploy-storybook -- --ci
58+
env:
59+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
60+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
node_modules
44
.cache
55
dist
6+
.history
7+
coverage

example/Demo.stories.tsx

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
import useSmoothScroll from 'react-smooth-scroll-hook';
2-
import React, { useRef } from 'react';
3-
4-
export const Demo = () => {
5-
const ref = useRef<HTMLDivElement>(null);
6-
const { scrollTo } = useSmoothScroll({
7-
ref,
8-
});
9-
10-
return (
11-
<>
12-
<button onClick={() => scrollTo('#y-item-20')} id={'demo-stories-btn-1'}>
13-
scrollTo('#y-item-20')
14-
</button>
15-
<button onClick={() => scrollTo(400)} id={'demo-stories-btn-2'}>
16-
scrollTo(400)
17-
</button>
18-
<br />
19-
<div
20-
id={'demo-stories'}
21-
ref={ref}
22-
style={{
23-
overflowY: 'scroll',
24-
maxHeight: '200px',
25-
padding: '10px',
26-
}}
27-
>
28-
{Array(100)
29-
.fill(null)
30-
.map((_item, i) => (
31-
<div key={i} id={`y-item-${i}`}>
32-
y-item-{i}
33-
</div>
34-
))}
35-
</div>
36-
</>
37-
);
38-
};
1+
import useSmoothScroll from 'react-smooth-scroll-hook';
2+
import React, { useRef } from 'react';
3+
4+
export const Demo = () => {
5+
const ref = useRef<HTMLDivElement>(null);
6+
const { scrollTo } = useSmoothScroll({
7+
ref,
8+
});
9+
10+
return (
11+
<>
12+
<button onClick={() => scrollTo('#y-item-20')}>
13+
scrollTo('#y-item-20')
14+
</button>
15+
<button onClick={() => scrollTo(400)}>scrollTo(400)</button>
16+
<br />
17+
<div
18+
id={'demo-stories'}
19+
ref={ref}
20+
style={{
21+
overflowY: 'scroll',
22+
maxHeight: '200px',
23+
padding: '10px',
24+
}}
25+
>
26+
{Array(100)
27+
.fill(null)
28+
.map((_item, i) => (
29+
<div key={i} id={`y-item-${i}`}>
30+
y-item-{i}
31+
</div>
32+
))}
33+
</div>
34+
</>
35+
);
36+
};

0 commit comments

Comments
 (0)