Skip to content

Commit

Permalink
feat: update tests files (#57)
Browse files Browse the repository at this point in the history
* feat: update tests files

* 2.6.0
  • Loading branch information
aykutkardas authored Jan 19, 2025
1 parent 9ee4172 commit 482db68
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 68 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules
/dist
/dist
deno.lock
11 changes: 11 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}
60 changes: 12 additions & 48 deletions src/index.test.tsx → src/index.test.jsx
Original file line number Diff line number Diff line change
@@ -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/[email protected]/testing/asserts.ts";
import { render } from "https://esm.sh/[email protected]";
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(
<IcoMoon iconSet={iconSet} icon="chat" size={22} />
);
expect(Icon).toBeDefined();
});

it("Check size props", () => {
const Icon = Enzyme.render(
<IcoMoon iconSet={iconSet} icon="chat" size={22} />
);
expect(Icon.prop("style").width).toEqual("22px");
expect(Icon.prop("style").height).toEqual("22px");
});

it("Check custom attribute", () => {
const Icon = Enzyme.render(
<IcoMoon iconSet={iconSet} icon="chat" size={22} data-name="chat" />
);
expect(Icon.prop("data-name")).toEqual("chat");
});

it("Check title attribute", () => {
const Icon = Enzyme.render(
<IcoMoon iconSet={iconSet} icon="chat" size={22} title="Chat" />
);
expect(Icon.find("title").text()).toEqual("Chat");
});
const Icon = render(<IcoMoon iconSet={iconSet} icon="chat" size={22} />);
assertEquals(Icon.includes("width: 22px"), true);
assertEquals(Icon.includes("height: 22px"), true);
assertEquals(Icon.includes("<title>Chat</title>"), 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() {
Expand Down

0 comments on commit 482db68

Please sign in to comment.