Skip to content

Commit

Permalink
Merge pull request #670 from evgenykochetkov/warn-about-duplicate-sto…
Browse files Browse the repository at this point in the history
…ry-name

Warn if story with a given name already exists
  • Loading branch information
ndelangen authored Mar 28, 2017
2 parents 45e5226 + c54097e commit a930b0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/client/preview/__tests__/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class StoryStore {
return fn;
}, null);
}

hasStory(kind, name) {
return Boolean(this.getStory(kind, name));
}
}

describe('preview.client_api', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export default class ClientApi {
});

api.add = (storyName, getStory) => {
if (this._storyStore.hasStory(kind, storyName)) {
throw new Error(`Story of "${kind}" named "${storyName}" already exists`);
}

// Wrap the getStory function with each decorator. The first
// decorator will wrap the story function. The second will
// wrap the first decorator and so on.
Expand Down

0 comments on commit a930b0c

Please sign in to comment.