Skip to content

Commit 0f2141a

Browse files
authored
Merge pull request #3 from storybookjs/feature/add-tests
Feature/add tests
2 parents abdf107 + 13183f8 commit 0f2141a

File tree

12 files changed

+1485
-815
lines changed

12 files changed

+1485
-815
lines changed

dev/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setConfig } from '../src/config';
22

33
setConfig({
4-
addId: 'dev_adk',
4+
addonId: 'dev_adk',
55
panelTitle: 'ADK DEV'
66
});

dev/register.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ const AddonBlock = styled(Block)`
2222

2323
const AddonPanel = ({
2424
api,
25-
data,
2625
kind,
2726
indInc,
2827
indDec,
2928
update,
29+
theme,
30+
data,
3031
}) => {
3132
return (
3233
<LayoutBlock style={{ padding: 0 }}>
@@ -55,7 +56,8 @@ register(
5556
{
5657
themeInd: store => store.currentTheme,
5758
themeList: store => store.themes,
58-
theme: store => store.themes[store.currentTheme]
59+
theme: store => store.themes[store.currentTheme],
60+
data: store => store
5961
},
6062
({ global, local }) => ({
6163
indInc: global(store => ({

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
roots: ['<rootDir>/src'],
3+
collectCoverage: true,
4+
collectCoverageFrom: ['src/**/*.js', '!**/node_modules/**'],
5+
coverageReporters: ['html', 'text'],
6+
moduleNameMapper: {
7+
'@storybook/addons': '<rootDir>/src/__tests__/__mocks__/storybook-addons.js'
8+
},
9+
testPathIgnorePatterns: ['/node_modules/', '/__mocks__/'],
10+
coverageThreshold: {
11+
global: {
12+
branches: 0,
13+
functions: 0,
14+
lines: 0,
15+
statements: 0,
16+
},
17+
},
18+
};

jsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"typeAcquisition": {
3+
"include": [
4+
"jest"
5+
]
6+
}
7+
}

nodemon.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"./dev/",
55
"./.storybook"
66
],
7-
"ext": "js"
7+
"ext": "js",
8+
"ignore": [
9+
"__tests__/**/"
10+
]
811

912
}

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
},
99
"main": "dist/index.js",
1010
"scripts": {
11+
"test": "jest",
12+
"tdd": "jest --watch",
1113
"prepare-storybook": "yarn prepare-dev && yarn prepare && start-storybook -p 9001 --ci",
1214
"start-storybook": "start-storybook -p 9001 --ci",
1315
"start": "nodemon --exec yarn start-storybook",
@@ -20,8 +22,8 @@
2022
"dependencies": {
2123
"@reach/rect": "^0.2.1",
2224
"@storybook/addons": "^5.0.11",
23-
"@storybook/theming": "^5.0.11",
2425
"@storybook/core-events": "^5.0.11",
26+
"@storybook/theming": "^5.0.11",
2527
"prop-types": "^15.6.2"
2628
},
2729
"devDependencies": {
@@ -30,14 +32,15 @@
3032
"@babel/plugin-proposal-class-properties": "^7.2.3",
3133
"@babel/preset-env": "^7.2.3",
3234
"@babel/preset-react": "^7.0.0",
33-
"@storybook/addon-actions": "^5.0.11",
34-
"@storybook/addon-backgrounds": "^5.0.11",
35-
"@storybook/addon-links": "5.0.11",
36-
"@storybook/react": "5.0.11",
35+
"@storybook/addon-actions": "^5.1.9",
36+
"@storybook/addon-backgrounds": "^5.1.9",
37+
"@storybook/addon-links": "^5.1.9",
38+
"@storybook/react": "^5.1.9",
3739
"babel-eslint": "^10.0.1",
3840
"babel-jest": "^24.7.1",
3941
"babel-loader": "^8.0.2",
4042
"nodemon": "^1.18.9",
43+
"prettier": "^1.18.2",
4144
"react": "16.8.6",
4245
"react-dom": "16.8.6",
4346
"react-scripts": "3.0.0"

src/ChannelStore.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ export default class ChannelStore {
2020
this.initData = initData;
2121
this.isPanel = isPanel;
2222
this.id = storyId;
23+
24+
this.store = {
25+
[GLOBAL]: { init: this.initData || {}, over: {} },
26+
};
2327
}
2428

25-
store = {
26-
[GLOBAL]: { init: this.initData || {}, over: {} },
27-
};
29+
2830
selectorId = null;
2931

3032
subscriber = () => {};
@@ -138,6 +140,7 @@ export default class ChannelStore {
138140
};
139141

140142
createGlobalAction = reducer => this._createAction(reducer, () => GLOBAL);
143+
141144
createLocalAction = reducer =>
142145
this._createAction(reducer, () => this.selectorId || this.id);
143146

@@ -154,6 +157,6 @@ export default class ChannelStore {
154157
let singleStore;
155158

156159
export const getSingleStore = (...args) => {
157-
singleStore = singleStore || new ChannelStore(...args)
160+
singleStore = singleStore || new ChannelStore(...args);
158161
return singleStore;
159162
};

0 commit comments

Comments
 (0)