mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
Add test-cases for config_api
This commit is contained in:
parent
5c3955446d
commit
10936a7b4f
35
src/client/__tests__/config_api.js
Normal file
35
src/client/__tests__/config_api.js
Normal file
@ -0,0 +1,35 @@
|
||||
const { describe, it } = global;
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('client.ConfigApi', () => {
|
||||
describe('_renderError', () => {
|
||||
it('should send error stack and message to syncedStore');
|
||||
});
|
||||
|
||||
describe('_renderMain', () => {
|
||||
it('should run loaders if provided');
|
||||
it('should set error in syncedStore to null');
|
||||
it('should get a dump of storyStore and send it to syncedStore');
|
||||
it('should set __updatedAt field with a updated value to syncedStore');
|
||||
it('should select a new kind if the current one is not available');
|
||||
describe('if there is kind', () => {
|
||||
it('should select a new story if the current one is not available');
|
||||
});
|
||||
});
|
||||
|
||||
describe('configure', () => {
|
||||
describe('initially', () => {
|
||||
it('should call _renderMain with loaders');
|
||||
describe('if caused an error', () => {
|
||||
it('should call _renderError with the error');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with hot reload', () => {
|
||||
it('should call _renderMain with loaders');
|
||||
describe('if caused an error', () => {
|
||||
it('should call _renderError with the error');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -4,7 +4,9 @@ export default class ConfigApi {
|
||||
this._storyStore = storyStore;
|
||||
}
|
||||
|
||||
_renderMain() {
|
||||
_renderMain(loaders) {
|
||||
if (loaders) loaders();
|
||||
|
||||
const data = this._syncedStore.getData();
|
||||
data.error = null;
|
||||
data.__updatedAt = Date.now();
|
||||
@ -34,8 +36,7 @@ export default class ConfigApi {
|
||||
configure(loaders, module) {
|
||||
const render = () => {
|
||||
try {
|
||||
loaders();
|
||||
this._renderMain();
|
||||
this._renderMain(loaders);
|
||||
} catch (error) {
|
||||
this._renderError(error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user