-
-
Notifications
You must be signed in to change notification settings - Fork 149
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 #142 from tbleckert/next
Refactoring
- Loading branch information
Showing
113 changed files
with
23,719 additions
and
14,870 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 |
---|---|---|
@@ -1,24 +1,50 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "airbnb", | ||
"plugins": [ | ||
"react-hooks" | ||
], | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"indent": ["error", 4], | ||
"react/jsx-indent": ["error", 4], | ||
"react/jsx-indent-props": ["error", 4], | ||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], | ||
"react/jsx-props-no-spreading": 0, | ||
"import/no-unresolved": [2, {"ignore": ["src/"]}], | ||
"jsx-a11y/click-events-have-key-events": 0, | ||
"no-mixed-operators": 0, | ||
"react-hooks/rules-of-hooks": "error", | ||
"react-hooks/exhaustive-deps": "warn", | ||
"jsx-a11y/no-autofocus": 0 | ||
} | ||
"parser": "babel-eslint", | ||
"extends": "airbnb", | ||
"plugins": [ | ||
"react-hooks" | ||
], | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"react/jsx-indent": [ | ||
"error", | ||
4 | ||
], | ||
"react/jsx-indent-props": [ | ||
"error", | ||
4 | ||
], | ||
"react/jsx-filename-extension": [ | ||
1, | ||
{ | ||
"extensions": [ | ||
".js", | ||
".jsx" | ||
] | ||
} | ||
], | ||
"react/jsx-props-no-spreading": 0, | ||
"import/no-unresolved": [ | ||
2, | ||
{ | ||
"ignore": [ | ||
"src/" | ||
] | ||
} | ||
], | ||
"jsx-a11y/click-events-have-key-events": 0, | ||
"no-mixed-operators": 0, | ||
"react-hooks/rules-of-hooks": "error", | ||
"react-hooks/exhaustive-deps": "warn", | ||
"jsx-a11y/no-autofocus": 0, | ||
"react/jsx-uses-react": "off", | ||
"react/react-in-jsx-scope": "off" | ||
} | ||
} |
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,31 +1,34 @@ | ||
|
||
module.exports = { | ||
stories: ['../stories/**/*.stories.js'], | ||
addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-storysource'], | ||
webpackFinal: async config => { | ||
const devMode = process.env.NODE_ENV !== 'production'; | ||
'stories': ['../stories/**/*.stories.js'], | ||
'addons': [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-storysource', | ||
'@storybook/addon-essentials' | ||
], | ||
webpackFinal: async config => { | ||
const devMode = process.env.NODE_ENV !== 'production'; | ||
|
||
// get index of css rule | ||
config.module.rules.find( | ||
rule => rule.test.toString() === '/\\.css$/', | ||
).exclude = /\.module\.css$/; | ||
// get index of css rule | ||
config.module.rules.find( | ||
rule => rule.test.toString() === '/\\.css$/', | ||
).exclude = /\.module\.css$/; | ||
|
||
config.module.rules.push({ | ||
test: /\.module\.css$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: { | ||
localIdentName: (devMode) ? 'mm-[name]__[local]--[hash:base64:5]' : '[hash:base64:5]', | ||
}, | ||
} | ||
}, | ||
] | ||
}); | ||
config.module.rules.push({ | ||
test: /\.module\.css$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: { | ||
localIdentName: (devMode) ? 'mm-[name]__[local]--[hash:base64:5]' : '[hash:base64:5]', | ||
}, | ||
} | ||
}, | ||
] | ||
}); | ||
|
||
// Return the altered config | ||
return config; | ||
}, | ||
// Return the altered config | ||
return config; | ||
}, | ||
}; |
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,4 @@ | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
} |
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,63 @@ | ||
import renderer from 'react-test-renderer'; | ||
import Option from '../src/Components/Option'; | ||
|
||
const optionProps = { | ||
tabIndex: '-1', | ||
onMouseDown: () => {}, | ||
}; | ||
|
||
describe('Test Option component', () => { | ||
test('Renders with default props', () => { | ||
const component = renderer.create( | ||
<Option | ||
option={{ | ||
name: 'Hamburger', | ||
value: 'hamburger', | ||
}} | ||
cls={(cls) => cls} | ||
highlighted={false} | ||
selected={false} | ||
optionProps={optionProps} | ||
/> | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('Highlighted', () => { | ||
const component = renderer.create( | ||
<Option | ||
option={{ | ||
name: 'Hamburger', | ||
value: 'hamburger', | ||
}} | ||
cls={(cls) => cls} | ||
highlighted={true} | ||
selected={false} | ||
optionProps={optionProps} | ||
/> | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('Selected', () => { | ||
const component = renderer.create( | ||
<Option | ||
option={{ | ||
name: 'Hamburger', | ||
value: 'hamburger', | ||
}} | ||
cls={(cls) => cls} | ||
highlighted={false} | ||
selected={true} | ||
optionProps={optionProps} | ||
/> | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import renderer from 'react-test-renderer'; | ||
import Options from '../src/Components/Options'; | ||
import { countries } from './data'; | ||
|
||
describe('Test Options component', () => { | ||
test('Not found', () => { | ||
const component = renderer.create( | ||
<Options | ||
options={[]} | ||
cls={(cls) => cls} | ||
emptyMessage="Not found" | ||
optionProps={{ | ||
tabIndex: '0', | ||
onMouseDown: () => {}, | ||
}} | ||
snapshot={{ | ||
highlighted: -1, | ||
option: null, | ||
focus: false, | ||
value: null, | ||
}} | ||
/> | ||
); | ||
|
||
const tree = component.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
|
||
expect(component.root.findAllByType('li').length).toBe(1); | ||
expect(component.root.findByType('li').props.className).toBe('not-found'); | ||
expect(component.root.findByType('li').props.children).toBe('Not found'); | ||
}); | ||
}); |
Oops, something went wrong.
23b09ef
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: