-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from lastcode802/feature/unit_Testing
Feature/unit testing
- Loading branch information
Showing
6 changed files
with
120 additions
and
5 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
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,74 @@ | ||
import { render, fireEvent } from "@testing-library/react"; | ||
import React from "react"; | ||
import ControlButton, { GlassArBtnProps } from "."; | ||
|
||
describe("ThreedView", () => { | ||
let props: GlassArBtnProps; | ||
beforeEach(() => { | ||
props = { | ||
backgroundColor: "red", | ||
color: "blue", | ||
onClick: jest.fn(), | ||
className: "test", | ||
children: "test", | ||
}; | ||
}); | ||
|
||
describe("ThreedView Button Render", () => { | ||
it("Add a Button", () => { | ||
const { container } = render(<ControlButton {...props} />); | ||
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access | ||
expect(container.querySelector(".JeelizVTOWidgetButton")).toBeTruthy(); | ||
}); | ||
}); | ||
describe("ThreedView Button Call", () => { | ||
it("Call Button", () => { | ||
const { container } = render(<ControlButton {...props} />); | ||
// eslint-disable-next-line testing-library/prefer-screen-queries, testing-library/no-container, testing-library/no-node-access | ||
const button: any = container.querySelector(".JeelizVTOWidgetButton"); | ||
fireEvent.click(button); | ||
expect(props.onClick).toHaveBeenCalled(); | ||
}); | ||
}); | ||
describe("ThreedView Button Click", () => { | ||
it("Click Button", () => { | ||
const { container } = render(<ControlButton {...props} />); | ||
// eslint-disable-next-line testing-library/prefer-screen-queries, testing-library/no-container, testing-library/no-node-access | ||
const button: any = container.querySelector(".JeelizVTOWidgetButton"); | ||
fireEvent.click(button); | ||
expect(props.onClick).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
describe("ThreedView Button Snap", () => { | ||
it("Snap Button", () => { | ||
const { container } = render(<ControlButton {...props} />); | ||
// eslint-disable-next-line testing-library/no-node-access | ||
expect(container.firstChild).toMatchInlineSnapshot(` | ||
<button | ||
class="JeelizVTOWidgetButton test" | ||
style="background-color: red; color: blue;" | ||
> | ||
test | ||
</button> | ||
`); | ||
}); | ||
it("Snap Button props change", () => { | ||
props.backgroundColor = "black"; | ||
props.color = "white"; | ||
props.className = "checkClass"; | ||
// eslint-disable-next-line testing-library/no-node-access | ||
props.children = "model btn"; | ||
|
||
const { container } = render(<ControlButton {...props} />); | ||
// eslint-disable-next-line testing-library/no-node-access | ||
expect(container.firstChild).toMatchInlineSnapshot(` | ||
<button | ||
class="JeelizVTOWidgetButton checkClass" | ||
style="background-color: black; color: white;" | ||
> | ||
model btn | ||
</button> | ||
`); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { render } from "@testing-library/react"; | ||
import React from "react"; | ||
import GlassArView, { GlassArViewProps } from "."; | ||
|
||
|
||
describe("ThreedView", () => { | ||
let props: GlassArViewProps; | ||
beforeEach(() => { | ||
props = { | ||
modelname: 'rayban_aviator_or_vertFlash', | ||
canvaswidth: 500, | ||
canvasheight: 500, | ||
buttonFontColor: 'white', | ||
buttonBackgroundColor: '#FFE5B4' | ||
}; | ||
}); | ||
|
||
describe("ThreedView Button Render", () => { | ||
it("Add a Button", () => { | ||
const { container } = render(<GlassArView {...props} />); | ||
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access | ||
expect(container.firstChild).toMatchInlineSnapshot() | ||
|
||
}); | ||
}); | ||
|
||
}); | ||
|
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