-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
31 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/node_modules | ||
/dist | ||
/dist | ||
deno.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|