From 482db68227857b2b59605b8ba0ff2acdec023260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aykut=20Karda=C5=9F?= Date: Sun, 19 Jan 2025 20:49:56 +0300 Subject: [PATCH] feat: update tests files (#57) * feat: update tests files * 2.6.0 --- .github/workflows/main.yml | 14 +++--- .gitignore | 3 +- deno.json | 11 +++++ package.json | 11 +---- src/{index.test.tsx => index.test.jsx} | 60 ++++++-------------------- 5 files changed, 31 insertions(+), 68 deletions(-) create mode 100644 deno.json rename src/{index.test.tsx => index.test.jsx} (65%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 951c902..6278e50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,16 +8,12 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x] + deno-version: [1.x] steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - name: Setup Deno + uses: denoland/setup-deno@v1 with: - node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm run build - - run: npm run test - env: - CI: true + deno-version: ${{ matrix.deno-version }} + - run: deno test diff --git a/.gitignore b/.gitignore index b2d59d1..4c2d17b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules -/dist \ No newline at end of file +/dist +deno.lock \ No newline at end of file diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..3b286b2 --- /dev/null +++ b/deno.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "jsx": "react", + "jsxFactory": "React.createElement", + "jsxFragmentFactory": "React.Fragment" + }, + "imports": { + "react": "https://esm.sh/react@17", + "@testing-library/react": "https://esm.sh/@testing-library/react@12" + } +} diff --git a/package.json b/package.json index a1f9a4c..526e271 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "react-icomoon", - "version": "2.5.7", + "version": "2.6.0", "description": "It makes it very simple to use SVG icons in your React and React-Native projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { - "test": "jest --env=jsdom", "build": "tsc" }, "repository": { @@ -31,14 +30,6 @@ "@babel/core": "^7.15.0", "@babel/preset-env": "^7.15.0", "@babel/preset-react": "^7.14.5", - "@testing-library/react": "^12.0.0", - "@wojtekmaj/enzyme-adapter-react-17": "^0.6.3", - "enzyme": "^3.11.0", - "enzyme-adapter-react-16": "^1.15.6", - "jest": "^27.0.6", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "ts-jest": "^27.0.4", "typescript": "^4.5.5" } } diff --git a/src/index.test.tsx b/src/index.test.jsx similarity index 65% rename from src/index.test.tsx rename to src/index.test.jsx index 3bcf8e2..94e1531 100644 --- a/src/index.test.tsx +++ b/src/index.test.jsx @@ -1,57 +1,21 @@ -import * as React from "react"; -import Enzyme from "enzyme"; -import Adapter from "@wojtekmaj/enzyme-adapter-react-17"; -import IcoMoon, { iconList } from "../dist/index"; +import { assertEquals } from "https://deno.land/std@0.110.0/testing/asserts.ts"; +import { render } from "https://esm.sh/preact-render-to-string@5.1.19"; +import IcoMoon, { iconList } from "./index.tsx"; +import React from "https://esm.sh/react@17"; -Enzyme.configure({ adapter: new Adapter() }); - -describe("IcoMoon Component Test", () => { +Deno.test("IcoMoon Component Test", () => { const iconSet = getIconSet(); - it("Check define", () => { - expect(IcoMoon).toBeDefined(); - }); - - it("Check render", () => { - const Icon = Enzyme.render( - - ); - expect(Icon).toBeDefined(); - }); - - it("Check size props", () => { - const Icon = Enzyme.render( - - ); - expect(Icon.prop("style").width).toEqual("22px"); - expect(Icon.prop("style").height).toEqual("22px"); - }); - it("Check custom attribute", () => { - const Icon = Enzyme.render( - - ); - expect(Icon.prop("data-name")).toEqual("chat"); - }); - - it("Check title attribute", () => { - const Icon = Enzyme.render( - - ); - expect(Icon.find("title").text()).toEqual("Chat"); - }); + const Icon = render(); + assertEquals(Icon.includes("width: 22px"), true); + assertEquals(Icon.includes("height: 22px"), true); + assertEquals(Icon.includes("Chat"), false); }); -describe("iconList Method Tests", () => { +Deno.test("iconList Method Tests", () => { const iconSet = getIconSet(); - - it("Check define", () => { - expect(iconList).toBeDefined(); - }); - - it("Check array of iconSet", () => { - const expected = ["chat"]; - expect(iconList(iconSet)).toEqual(expect.arrayContaining(expected)); - }); + const expected = ["chat"]; + assertEquals(iconList(iconSet), expected); }); function getIconSet() {