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 #37 from DiogoMalfatti/jest-config
feat: jest ok
- Loading branch information
Showing
10 changed files
with
18,923 additions
and
10,887 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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`config/redirects renders all current redirects 1`] = ` | ||
Array [ | ||
Object { | ||
"destination": "/app/login/", | ||
"permanent": true, | ||
"source": "/login/", | ||
}, | ||
] | ||
`; |
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 @@ | ||
import redirects from './redirects'; | ||
|
||
// Test Driven Development | ||
describe('config/redirects', () => { | ||
test('renders all current redirects', () => { | ||
expect(redirects).toMatchSnapshot(); // Fotografia/Insta/Polaroid | ||
}); | ||
}); |
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,12 @@ | ||
module.exports = { | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
moduleDirectories: [ | ||
'<rootDir>/node_modules', | ||
'node_modules', | ||
], | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.next/', | ||
'<rootDir>/cypress/', | ||
'<rootDir>/dist/', | ||
], | ||
}; |
Empty file.
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 was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/theme/utils/propToStyle/__snapshots__/propToStyle.test.js.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,38 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`propToStyle() when receives an argument with breakpoints renders only one breakpoint resolution 1`] = ` | ||
Array [ | ||
Array [ | ||
"@media screen and (min-width:", | ||
"0", | ||
"px){", | ||
"text-align: center;", | ||
"}", | ||
], | ||
Array [ | ||
"@media screen and (min-width:", | ||
"768", | ||
"px){", | ||
"}", | ||
], | ||
] | ||
`; | ||
exports[`propToStyle() when receives an argument with breakpoints renders two or more breakpoint resolutions 1`] = ` | ||
Array [ | ||
Array [ | ||
"@media screen and (min-width:", | ||
"0", | ||
"px){", | ||
"text-align: center;", | ||
"}", | ||
], | ||
Array [ | ||
"@media screen and (min-width:", | ||
"768", | ||
"px){", | ||
"text-align: right;", | ||
"}", | ||
], | ||
] | ||
`; |
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,43 @@ | ||
import { breakpointsMedia } from '../breakpointsMedia'; | ||
|
||
export function propToStyle(propName) { | ||
return (props) => { | ||
const propValue = props[propName]; | ||
|
||
if (typeof propValue === 'string' || typeof propValue === 'number') { | ||
return { | ||
// textAlign: props.textAlign | ||
[propName]: propValue, | ||
}; | ||
} | ||
|
||
if (typeof propValue === 'object') { | ||
const breakpoints = {}; | ||
|
||
if (propValue.xs) breakpoints.xs = { [propName]: propValue.xs }; | ||
if (propValue.md) breakpoints.md = { [propName]: propValue.md }; | ||
|
||
return breakpointsMedia(breakpoints); | ||
|
||
// return breakpointsMedia({ | ||
// xs: { | ||
// [propName]: propValue.xs, | ||
// }, | ||
// sm: { | ||
// [propName]: propValue.sm, | ||
// }, | ||
// md: { | ||
// [propName]: propValue.md, | ||
// }, | ||
// lg: { | ||
// [propName]: propValue.lg, | ||
// }, | ||
// xl: { | ||
// [propName]: propValue.xl, | ||
// }, | ||
// }); | ||
} | ||
|
||
return {}; | ||
}; | ||
} |
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,39 @@ | ||
import { propToStyle } from './index'; | ||
|
||
describe('propToStyle()', () => { | ||
describe('when receives an simple argument', () => { | ||
test('and it is a string', () => { | ||
const propToStyleResult = propToStyle('textAlign'); | ||
// <Text textAlign="center" /> | ||
const componentProps = { textAlign: 'center' }; // string | ||
const styleResult = propToStyleResult(componentProps); | ||
expect(styleResult).toEqual({ textAlign: 'center' }); | ||
}); | ||
test('and it is a number', () => { | ||
const propToStyleResult = propToStyle('flex'); | ||
// <Text flex={1} /> | ||
const componentProps = { flex: 1 }; // number | ||
const styleResult = propToStyleResult(componentProps); | ||
expect(styleResult).toEqual({ flex: 1 }); | ||
}); | ||
}); | ||
|
||
describe('when receives an argument with breakpoints', () => { | ||
test('renders only one breakpoint resolution', () => { | ||
const propToStyleResult = propToStyle('textAlign'); | ||
// <Text textAlign="center" /> | ||
const componentProps = { textAlign: { xs: 'center' } }; // string | ||
const styleResult = propToStyleResult(componentProps); | ||
|
||
expect(styleResult).toMatchSnapshot(); | ||
}); | ||
test('renders two or more breakpoint resolutions', () => { | ||
const propToStyleResult = propToStyle('textAlign'); | ||
// <Text textAlign="center" /> | ||
const componentProps = { textAlign: { xs: 'center', md: 'right' } }; // string | ||
const styleResult = propToStyleResult(componentProps); | ||
|
||
expect(styleResult).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
82c8114
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: