Skip to content

Commit fd4ef9f

Browse files
committed
chore: 🤖 Update to the workflows
1 parent d2c4f55 commit fd4ef9f

13 files changed

Lines changed: 223 additions & 139 deletions

File tree

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Node
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: "16"
18+
node-version: "20"
1919
cache: "yarn"
2020

2121
- name: Install packages

.github/workflows/release.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/workflow.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Tests
2+
3+
on: push
4+
5+
jobs:
6+
prepare-environment:
7+
runs-on: ubuntu-latest
8+
name: Prepare environment
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
- uses: actions/setup-node@v3
13+
with:
14+
node-version: "20"
15+
cache: "yarn"
16+
cache-dependency-path: yarn.lock
17+
env:
18+
FORCE_COLOR: 0
19+
- name: Install node_modules on cache miss
20+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
21+
run: yarn install --frozen-lockfile
22+
- name: Cache node_modules
23+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
24+
uses: actions/cache/save@v3
25+
with:
26+
path: node_modules
27+
key: yarn-${{ hashFiles('yarn.lock') }}
28+
29+
tests:
30+
name: Run tests
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
36+
- name: Set up Node.js
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: "20"
40+
cache: "yarn"
41+
42+
- name: Restore node_modules
43+
uses: actions/cache/restore@v3
44+
id: cache-node-modules
45+
with:
46+
path: node_modules
47+
key: yarn-${{ hashFiles('yarn.lock') }}
48+
fail-on-cache-miss: false
49+
- name: Install node_modules on cache miss
50+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
51+
run: yarn install --frozen-lockfile
52+
53+
- name: Build
54+
run: yarn build
55+
56+
- name: Lint
57+
run: yarn lint
58+
59+
- name: Typecheck
60+
run: yarn typecheck
61+
62+
- name: Clear Jest
63+
run: yarn jest --clearCache
64+
65+
- name: Test
66+
run: yarn test --coverage
67+
68+
# - name: Send Report
69+
# uses: paambaati/codeclimate-action@v3.0.0
70+
# env:
71+
# CC_TEST_REPORTER_ID: 7d1e3713df373ab2c9efce24b85c16efa2bd953aae32bd9d278004784d71291e
72+
# with:
73+
# coverageLocations: ${{github.workspace}}/coverage/lcov.info:lcov
74+
75+
release:
76+
name: Release
77+
if: ${{ github.ref == 'refs/heads/master' }}
78+
runs-on: ubuntu-latest
79+
needs: tests
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v3
83+
- name: Set up Node.js
84+
uses: actions/setup-node@v3
85+
with:
86+
node-version: "20"
87+
cache: "yarn"
88+
cache-dependency-path: yarn.lock
89+
- name: Restore node_modules
90+
uses: actions/cache/restore@v3
91+
id: cache-node-modules
92+
with:
93+
path: node_modules
94+
key: yarn-${{ hashFiles('yarn.lock') }}
95+
fail-on-cache-miss: false
96+
- name: Install node_modules on cache miss
97+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
98+
run: yarn install --frozen-lockfile
99+
- name: Build
100+
run: yarn build
101+
- name: Publish
102+
run: yarn release
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

__tests__/features/base/rendering.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe("Example view", () => {
88
expect(wrapper).toBeDefined();
99
});
1010
test("it renders center in button without errors", () => {
11-
const { center } = renderApp();
11+
const { centerBtn } = renderApp();
1212

13-
expect(center).toBeDefined();
13+
expect(centerBtn).toBeDefined();
1414
});
1515
test("it renders zoom in button without errors", () => {
1616
const { zoomInBtn } = renderApp();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { fireEvent, waitFor } from "@testing-library/react";
2+
3+
import { renderApp } from "../../utils/render-app";
4+
import { sleep } from "../../utils";
5+
6+
describe("Controls [Center]", () => {
7+
describe("When centering with controls button", () => {
8+
it("should change css transform", async () => {
9+
const { content, wrapper, centerBtn, zoom } = renderApp();
10+
zoom({ value: 1.65 });
11+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)");
12+
fireEvent(centerBtn, new MouseEvent("click", { bubbles: true }));
13+
await waitFor(() => {
14+
expect(content.style.transform).toBe(
15+
"translate(-162.5px, -162.5px) scale(1.65)",
16+
);
17+
});
18+
});
19+
});
20+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { fireEvent, waitFor } from "@testing-library/react";
2+
3+
import { renderApp } from "../../utils/render-app";
4+
import { sleep } from "../../utils";
5+
6+
describe("Controls [Reset]", () => {
7+
describe("When resetting state with controls button", () => {
8+
it("should change css scale", async () => {
9+
const { content, resetBtn, zoom } = renderApp();
10+
zoom({ value: 1.65 });
11+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)");
12+
fireEvent(resetBtn, new MouseEvent("click", { bubbles: true }));
13+
await waitFor(() => {
14+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
15+
});
16+
});
17+
});
18+
});
Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
import { fireEvent, waitFor } from "@testing-library/react";
22

33
import { renderApp } from "../../utils/render-app";
4+
import { sleep } from "../../utils";
45

5-
describe("Controls [Base]", () => {
6+
describe("Controls [Zoom]", () => {
67
describe("When zooming in with controls button", () => {
7-
// it("should increase css scale with animated zoom", async () => {
8-
// const { content, zoomInBtn } = renderApp();
9-
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
10-
// fireEvent(zoomInBtn, new MouseEvent("click", { bubbles: true }));
11-
// // Animation starts
12-
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
13-
// await waitFor(() => {
14-
// // Animation ends
15-
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)");
16-
// });
17-
// });
8+
it("should change css scale", async () => {
9+
const { content, zoomInBtn, centerBtn } = renderApp();
10+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
11+
fireEvent(zoomInBtn, new MouseEvent("click", { bubbles: true }));
12+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
13+
await waitFor(() => {
14+
expect(content.style.transform).toBe(
15+
"translate(-162.5px, -162.5px) scale(1.65)",
16+
);
17+
});
18+
fireEvent(centerBtn, new MouseEvent("click", { bubbles: true }));
19+
await sleep(40);
20+
await waitFor(() => {
21+
expect(content.style.transform).toBe(
22+
"translate(-162.5px, -162.5px) scale(1.65)",
23+
);
24+
});
25+
});
26+
});
27+
describe("When zooming out with controls button", () => {
28+
it("should change css scale", async () => {
29+
const { content, zoomOutBtn, zoom } = renderApp();
30+
31+
zoom({ value: 1.65 });
32+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1.65)");
33+
fireEvent(zoomOutBtn, new MouseEvent("click", { bubbles: true }));
34+
await waitFor(() => {
35+
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
36+
});
37+
});
1838
});
1939
});

__tests__/features/pan/pan.base.spec.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,4 @@ describe("Pan [Base]", () => {
8484
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
8585
});
8686
});
87-
88-
// describe("When max position is set", () => {
89-
// it("should not exceed max position", async () => {
90-
// const { content, pan } = renderApp({
91-
// maxPositionX: 20,
92-
// maxPositionY: 20,
93-
// });
94-
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
95-
// pan({ x: 200, y: 200 });
96-
// expect(content.style.transform).toBe("translate(20px, 20px) scale(1)");
97-
// pan({ x: -20, y: -20 });
98-
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
99-
// });
100-
// it("should not exceed min position", async () => {
101-
// const { content, pan } = renderApp({
102-
// minPositionX: 30,
103-
// minPositionY: 30,
104-
// });
105-
// expect(content.style.transform).toBe("translate(30px, 30px) scale(1)");
106-
// pan({ x: -20, y: -20 });
107-
// expect(content.style.transform).toBe("translate(30px, 30px) scale(1)");
108-
// pan({ x: 50, y: 50 });
109-
// expect(content.style.transform).toBe("translate(80px, 80px) scale(1)");
110-
// });
111-
// });
11287
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { waitFor } from "@testing-library/react";
2+
3+
import { renderApp } from "../../utils";
4+
5+
describe("Pan [Bounds]", () => {
6+
it("TODO", () => {
7+
expect(true).toBe(true);
8+
});
9+
// describe("When max position is set", () => {
10+
// it("should not exceed max position", async () => {
11+
// const { content, pan } = renderApp({
12+
// maxPositionX: 20,
13+
// maxPositionY: 20,
14+
// });
15+
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
16+
// pan({ x: -200, y: -200 });
17+
// expect(content.style.transform).toBe("translate(20px, 20px) scale(1)");
18+
// pan({ x: -20, y: -20 });
19+
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)");
20+
// });
21+
// it("should not exceed min position", async () => {
22+
// const { content, pan } = renderApp({
23+
// minPositionX: 30,
24+
// minPositionY: 30,
25+
// });
26+
// expect(content.style.transform).toBe("translate(30px, 30px) scale(1)");
27+
// pan({ x: -20, y: -20 });
28+
// expect(content.style.transform).toBe("translate(30px, 30px) scale(1)");
29+
// pan({ x: 50, y: 50 });
30+
// expect(content.style.transform).toBe("translate(80px, 80px) scale(1)");
31+
// });
32+
// });
33+
});

0 commit comments

Comments
 (0)