-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from Eureka-Shoulders/feat/tests#4
Feat/tests
- Loading branch information
Showing
19 changed files
with
724 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Chromatic | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
release: | ||
types: [created] | ||
jobs: | ||
chromatic: | ||
name: Publish Storybook on chromatic | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install dependencies | ||
run: yarn && yarn add @mui/material @emotion/react @emotion/styled inversify inversify-react mobx mobx-react-lite | ||
|
||
- name: Lint | ||
run: yarn lint | ||
|
||
- name: Publish to Chromatic | ||
uses: chromaui/action@v1 | ||
with: | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |
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
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
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,75 @@ | ||
import 'reflect-metadata'; | ||
|
||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { globalContainer } from 'index'; | ||
import { Provider } from 'inversify-react'; | ||
import { BreadcrumbsContainer } from '../../tests/fixtures/BreadcrumbFixtures'; | ||
|
||
describe('Breadcrumbs', () => { | ||
let onClickSpy: jest.Mock; | ||
|
||
beforeEach(() => { | ||
onClickSpy = jest.fn(); | ||
}); | ||
|
||
it('should renders correctly', async () => { | ||
const paths = [ | ||
{ | ||
label: 'Home', | ||
}, | ||
{ | ||
label: 'About', | ||
}, | ||
]; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<BreadcrumbsContainer newPaths={paths} /> | ||
</Provider> | ||
); | ||
|
||
expect(await screen.findByText(/Home/i)).not.toBeNull(); | ||
}); | ||
|
||
it('should call onClick function when the user clicks', async () => { | ||
const paths = [ | ||
{ | ||
label: 'Home', | ||
onClick: onClickSpy, | ||
}, | ||
{ | ||
label: 'About', | ||
}, | ||
]; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<BreadcrumbsContainer newPaths={paths} /> | ||
</Provider> | ||
); | ||
(await screen.findByText(/Home/i)).click(); | ||
expect(onClickSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should disable last path', async () => { | ||
const paths = [ | ||
{ | ||
label: 'Home', | ||
}, | ||
{ | ||
label: 'About', | ||
onClick: onClickSpy, | ||
}, | ||
]; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<BreadcrumbsContainer newPaths={paths} /> | ||
</Provider> | ||
); | ||
|
||
(await screen.findByText(/About/i)).click(); | ||
expect(onClickSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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,91 @@ | ||
import 'reflect-metadata'; | ||
|
||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { globalContainer } from 'index'; | ||
import { Provider } from 'inversify-react'; | ||
import { DialogContainer } from '../../tests/fixtures/DialogFixtures'; | ||
|
||
describe('Dialog', () => { | ||
let onRejectSpy: jest.Mock; | ||
let onAcceptSpy: jest.Mock; | ||
|
||
beforeEach(() => { | ||
onAcceptSpy = jest.fn(); | ||
onRejectSpy = jest.fn(); | ||
}); | ||
|
||
it('should renders correctly', async () => { | ||
const content = { | ||
title: 'Test title', | ||
onReject: onRejectSpy, | ||
onAccept: onAcceptSpy, | ||
content: 'Test content', | ||
}; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<DialogContainer newContent={content} /> | ||
</Provider> | ||
); | ||
|
||
expect(await screen.findByText(/Test content/i)).not.toBeNull(); | ||
}); | ||
|
||
it('should call onAccept function when the user clicks', async () => { | ||
const content = { | ||
title: 'Test title', | ||
onReject: onRejectSpy, | ||
onAccept: onAcceptSpy, | ||
content: 'Test content', | ||
}; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<DialogContainer | ||
newContent={content} | ||
props={{ confirmLabel: 'Confirm', cancelLabel: 'Cancel' }} | ||
/> | ||
</Provider> | ||
); | ||
(await screen.findByText(/Confirm/i)).click(); | ||
expect(onAcceptSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call onReject function when the user clicks', async () => { | ||
const content = { | ||
title: 'Test title', | ||
onReject: onRejectSpy, | ||
onAccept: onAcceptSpy, | ||
content: 'Test content', | ||
}; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<DialogContainer | ||
newContent={content} | ||
props={{ confirmLabel: 'Confirm', cancelLabel: 'Cancel' }} | ||
/> | ||
</Provider> | ||
); | ||
(await screen.findByText(/Cancel/i)).click(); | ||
expect(onRejectSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render a JSX as content', () => { | ||
const content = { | ||
title: 'Test title', | ||
onReject: onRejectSpy, | ||
onAccept: onAcceptSpy, | ||
content: <div>Test content</div>, | ||
}; | ||
|
||
render( | ||
<Provider container={globalContainer}> | ||
<DialogContainer newContent={content} /> | ||
</Provider> | ||
); | ||
|
||
expect(screen.getByText(/Test content/i)).not.toBeNull(); | ||
}); | ||
}); |
Oops, something went wrong.