mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
added tests
This commit is contained in:
parent
f68286f39a
commit
c9d3426fae
@ -112,6 +112,65 @@ describe('preview.client_api', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('addParameters', () => {
|
||||
it('should add parameters', () => {
|
||||
const { clientApi } = getContext();
|
||||
|
||||
clientApi.addParameters({ a: '1' });
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
expect(clientApi._globalParameters).toEqual({ a: '1', options: {} });
|
||||
});
|
||||
|
||||
it('should merge options', () => {
|
||||
const { clientApi } = getContext();
|
||||
|
||||
clientApi.addParameters({ options: { a: '1' } });
|
||||
clientApi.addParameters({ options: { b: '2' } });
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
expect(clientApi._globalParameters).toEqual({ options: { a: '1', b: '2' } });
|
||||
});
|
||||
|
||||
it('should override specific properties in options', () => {
|
||||
const { clientApi } = getContext();
|
||||
|
||||
clientApi.addParameters({ backgrounds: ['value'], options: { a: '1', b: '3' } });
|
||||
clientApi.addParameters({ options: { a: '2' } });
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
expect(clientApi._globalParameters).toEqual({
|
||||
backgrounds: ['value'],
|
||||
options: { a: '2', b: '3' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should replace top level properties and override specific properties in options', () => {
|
||||
const { clientApi } = getContext();
|
||||
|
||||
clientApi.addParameters({ backgrounds: ['value'], options: { a: '1', b: '3' } });
|
||||
clientApi.addParameters({ backgrounds: [], options: { a: '2' } });
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
expect(clientApi._globalParameters).toEqual({
|
||||
backgrounds: [],
|
||||
options: { a: '2', b: '3' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should deep merge in options', () => {
|
||||
const { clientApi } = getContext();
|
||||
|
||||
clientApi.addParameters({ options: { a: '1', b: '2', theming: { c: '3' } } });
|
||||
clientApi.addParameters({ options: { theming: { c: '4', d: '5' } } });
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
expect(clientApi._globalParameters).toEqual({
|
||||
options: { a: '1', b: '2', theming: { c: '4', d: '5' } },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('addDecorator', () => {
|
||||
it('should add local decorators', () => {
|
||||
const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user