-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/fliotta/tiquet into master
- Loading branch information
Showing
16 changed files
with
8,876 additions
and
3,552 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,20 @@ | ||
import { defaults } from 'jest-config'; | ||
|
||
export default { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
"^.+\\.svg$": "<rootDir>/svgTransform.ts" | ||
}, | ||
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$', | ||
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'], | ||
roots: ["<rootDir>/src"], | ||
setupFilesAfterEnv: [ | ||
"@testing-library/jest-dom/extend-expect" | ||
], | ||
moduleNameMapper: { | ||
"\\.(css|less|scss|sss|styl)$": "<rootDir>/node_modules/jest-css-modules", | ||
'^@backend/(.*)$': '<rootDir>/../server/src/api/$1', | ||
}, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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
17 changes: 17 additions & 0 deletions
17
client/src/components/EditableText/__test__/__snapshots__/index.test.tsx.snap
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,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<EditableText /> Matches snapshot 1`] = ` | ||
<div | ||
class="editable-text" | ||
> | ||
<p | ||
class="editable-text__title" | ||
> | ||
test text | ||
<i | ||
class="fas fa-pencil-alt editable-text__icon" | ||
/> | ||
</p> | ||
</div> | ||
`; |
115 changes: 115 additions & 0 deletions
115
client/src/components/EditableText/__test__/index.test.tsx
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,115 @@ | ||
// Packages | ||
import * as React from 'react'; | ||
import { render, fireEvent, screen, act } from '@testing-library/react'; | ||
|
||
// Project | ||
import EditableText from '../index'; | ||
|
||
|
||
describe('<EditableText />', () => { | ||
it('Matches snapshot', () => { | ||
const { container } = render( | ||
<EditableText | ||
text="test text" | ||
tag="p" | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('Receives text', () => { | ||
const testText = 'testText'; | ||
|
||
const { container } = render( | ||
<EditableText | ||
text={testText} | ||
tag='p' | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
expect(container.firstChild).toHaveTextContent(testText); | ||
}); | ||
|
||
it('Receives tag', () => { | ||
const testTag = 'p'; | ||
|
||
const { container } = render( | ||
<EditableText | ||
text='testText' | ||
tag={testTag} | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
expect(container.firstChild.firstChild.nodeName.toLowerCase()).toBe(testTag); | ||
}); | ||
|
||
it('Editable mode', () => { | ||
const { container } = render( | ||
<EditableText | ||
text='testText' | ||
tag='p' | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
fireEvent.click(container.firstChild); | ||
|
||
expect(screen.getByRole('textbox')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Input receives classname', () => { | ||
const inputClassName = 'testClassname'; | ||
|
||
const { container } = render( | ||
<EditableText | ||
text='testText' | ||
inputClassName={inputClassName} | ||
tag='p' | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
fireEvent.click(container.firstChild); | ||
|
||
expect(screen.getByRole('textbox')).toHaveClass(inputClassName); | ||
}); | ||
|
||
it('Input receives default text', () => { | ||
const textValue = 'Some test value'; | ||
|
||
const { container } = render( | ||
<EditableText | ||
text={textValue} | ||
tag='p' | ||
onSuccess={jest.fn()} | ||
/> | ||
); | ||
|
||
fireEvent.click(container.firstChild); | ||
|
||
expect(screen.getByRole('textbox').getAttribute('value')).toBe(textValue); | ||
}); | ||
|
||
it('onSuccess called', async () => { | ||
const onSuccess = jest.fn(); | ||
|
||
const { container } = render( | ||
<EditableText | ||
text='testtext' | ||
tag='p' | ||
onSuccess={onSuccess} | ||
/> | ||
); | ||
|
||
fireEvent.click(container.firstChild); | ||
await act(async () => { | ||
fireEvent.submit(screen.getByRole('form')); | ||
}); | ||
|
||
expect(onSuccess).toBeCalledTimes(1); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
client/src/components/Loading/__test__/__snapshots__/index.test.tsx.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Loading /> Matches snapshot 1`] = ` | ||
<div | ||
class="loading" | ||
> | ||
<img | ||
src="[object Object]" | ||
/> | ||
</div> | ||
`; |
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,24 @@ | ||
// Packages | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
// Project | ||
import Loading from '../index'; | ||
|
||
|
||
describe('<Loading />', () => { | ||
it('Matches snapshot', () => { | ||
const { container } = render( | ||
<Loading display /> | ||
); | ||
|
||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('Not visible when false display prop', () => { | ||
const { container } = render( | ||
<Loading /> | ||
); | ||
expect(container.firstChild).toHaveClass('loading--hidden'); | ||
}); | ||
}); |
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
17 changes: 17 additions & 0 deletions
17
client/src/components/OAuth/Github/__test__/__snapshots__/index.test.tsx.snap
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,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<GithubOAuth /> Matches snapshot 1`] = ` | ||
<div | ||
class="oauth-github" | ||
> | ||
<i | ||
aria-hidden="true" | ||
class="oauth-github__icon fab fa-github" | ||
/> | ||
<p | ||
class="oauth-github__text" | ||
> | ||
Auth with Github | ||
</p> | ||
</div> | ||
`; |
27 changes: 27 additions & 0 deletions
27
client/src/components/OAuth/Github/__test__/index.test.tsx
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 @@ | ||
// Packages | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
// Project | ||
import GithubOAuth from '../index'; | ||
|
||
|
||
describe('<GithubOAuth />', () => { | ||
it('Matches snapshot', () => { | ||
const { container } = render( | ||
<GithubOAuth onSuccess={jest.fn()} /> | ||
); | ||
|
||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('Receives text', () => { | ||
const testText = 'testText'; | ||
|
||
const { container } = render( | ||
<GithubOAuth onSuccess={jest.fn()} text={testText} /> | ||
); | ||
|
||
expect(container.firstChild).toHaveTextContent('testText'); | ||
}); | ||
}); |
Empty file.
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 @@ | ||
import '@testing-library/jest-dom/extend-expect' |
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,8 @@ | ||
module.exports = { | ||
process() { | ||
return 'module.exports = {};'; | ||
}, | ||
getCacheKey() { | ||
return 'svgTransform'; | ||
}, | ||
} |
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