Best JavaScript code snippet using storybook-root
make-decorator.test.js
Source:make-decorator.test.js
...15 it('returns a decorator that passes parameters on the parameters argument', () => {16 const wrapper = jest.fn();17 const decorator = makeDecorator({ wrapper, name: 'test', parameterName: 'test' });18 const story = jest.fn();19 const decoratedStory = defaultDecorateStory(story, [decorator]);20 const context = { parameters: { test: 'test-val' } };21 decoratedStory(context);22 expect(wrapper).toHaveBeenCalledWith(expect.any(Function), context, { parameters: 'test-val' });23 });24 it('passes options added at decoration time', () => {25 const wrapper = jest.fn();26 const decorator = makeDecorator({ wrapper, name: 'test', parameterName: 'test' });27 const story = jest.fn();28 const options = 'test-val';29 const decoratedStory = defaultDecorateStory(story, [decorator(options)]);30 const context = {};31 decoratedStory(context);32 expect(wrapper).toHaveBeenCalledWith(expect.any(Function), context, { options: 'test-val' });33 });34 it('passes both options *and* parameters at the same time', () => {35 const wrapper = jest.fn();36 const decorator = makeDecorator({ wrapper, name: 'test', parameterName: 'test' });37 const story = jest.fn();38 const options = 'test-val';39 const decoratedStory = defaultDecorateStory(story, [decorator(options)]);40 const context = { parameters: { test: 'test-val' } };41 decoratedStory(context);42 expect(wrapper).toHaveBeenCalledWith(expect.any(Function), context, {43 options: 'test-val',44 parameters: 'test-val',45 });46 });47 it('passes nothing if neither are supplied', () => {48 const wrapper = jest.fn();49 const decorator = makeDecorator({ wrapper, name: 'test', parameterName: 'test' });50 const story = jest.fn();51 const decoratedStory = defaultDecorateStory(story, [decorator]);52 const context = {};53 decoratedStory(context);54 expect(wrapper).toHaveBeenCalledWith(expect.any(Function), context, {});55 });56 it('calls the story directly if neither options or parameters are supplied and skipIfNoParametersOrOptions is true', () => {57 const wrapper = jest.fn();58 const decorator = makeDecorator({59 wrapper,60 name: 'test',61 parameterName: 'test',62 skipIfNoParametersOrOptions: true,63 });64 const story = jest.fn();65 const decoratedStory = defaultDecorateStory(story, [decorator]);66 const context = {};67 decoratedStory(context);68 expect(wrapper).not.toHaveBeenCalled();69 expect(story).toHaveBeenCalled();70 });71 it('calls the story directly if the disable parameter is passed to the decorator', () => {72 const wrapper = jest.fn();73 const decorator = makeDecorator({74 wrapper,75 name: 'test',76 parameterName: 'test',77 skipIfNoParametersOrOptions: true,78 });79 const story = jest.fn();80 const decoratedStory = defaultDecorateStory(story, [decorator]);81 const context = { disable: true };82 decoratedStory(context);83 expect(wrapper).not.toHaveBeenCalled();84 expect(story).toHaveBeenCalled();85 });86 it('passes options added at story time, but with a deprecation warning, if allowed', () => {87 deprecatedFns = [];88 const wrapper = jest.fn();89 const decorator = makeDecorator({90 wrapper,91 name: 'test',92 parameterName: 'test',93 allowDeprecatedUsage: true,94 });...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!