@@ -134,62 +134,62 @@ describe('preview.client_api', () => {
134134 const storyStore = new StoryStore ( ) ;
135135 const api = new ClientAPI ( { storyStore } ) ;
136136 const localApi = api . storiesOf ( 'none' ) ;
137- localApi . addDecorator ( fn => `aa- ${ fn ( ) } ` ) ;
137+ localApi . addDecorator ( fn => ( { template : `<div>aa ${ fn ( ) . template } </div>` } ) ) ;
138138
139- localApi . add ( 'storyName' , ( ) => 'Hello' ) ;
140- expect ( storyStore . stories [ 0 ] . fn ( ) ) . toBe ( 'aa-Hello ' ) ;
139+ localApi . add ( 'storyName' , ( ) => ( { template : '<p>hello</p>' } ) ) ;
140+ expect ( storyStore . stories [ 0 ] . fn ( ) . template ) . toBe ( '<div>aa<p>hello</p></div> ' ) ;
141141 } ) ;
142142
143143 it ( 'should add global decorators' , ( ) => {
144144 const storyStore = new StoryStore ( ) ;
145145 const api = new ClientAPI ( { storyStore } ) ;
146- api . addDecorator ( fn => `bb- ${ fn ( ) } ` ) ;
146+ api . addDecorator ( fn => ( { template : `<div>bb ${ fn ( ) . template } </div>` } ) ) ;
147147 const localApi = api . storiesOf ( 'none' ) ;
148148
149- localApi . add ( 'storyName' , ( ) => 'Hello' ) ;
150- expect ( storyStore . stories [ 0 ] . fn ( ) ) . toBe ( 'bb-Hello ' ) ;
149+ localApi . add ( 'storyName' , ( ) => ( { template : '<p>hello</p>' } ) ) ;
150+ expect ( storyStore . stories [ 0 ] . fn ( ) . template ) . toBe ( '<div>bb<p>hello</p></div> ' ) ;
151151 } ) ;
152152
153153 it ( 'should utilize both decorators at once' , ( ) => {
154154 const storyStore = new StoryStore ( ) ;
155155 const api = new ClientAPI ( { storyStore } ) ;
156156 const localApi = api . storiesOf ( 'none' ) ;
157157
158- api . addDecorator ( fn => `aa- ${ fn ( ) } ` ) ;
159- localApi . addDecorator ( fn => `bb- ${ fn ( ) } ` ) ;
158+ api . addDecorator ( fn => ( { template : `<div>aa ${ fn ( ) . template } </div>` } ) ) ;
159+ localApi . addDecorator ( fn => ( { template : `<div>bb ${ fn ( ) . template } </div>` } ) ) ;
160160
161- localApi . add ( 'storyName' , ( ) => 'Hello' ) ;
162- expect ( storyStore . stories [ 0 ] . fn ( ) ) . toBe ( 'aa-bb-Hello ' ) ;
161+ localApi . add ( 'storyName' , ( ) => ( { template : '<p>hello</p>' } ) ) ;
162+ expect ( storyStore . stories [ 0 ] . fn ( ) . template ) . toBe ( '<div>aa<div>bb<p>hello</p></div></div> ' ) ;
163163 } ) ;
164164
165165 it ( 'should pass the context' , ( ) => {
166166 const storyStore = new StoryStore ( ) ;
167167 const api = new ClientAPI ( { storyStore } ) ;
168168 const localApi = api . storiesOf ( 'none' ) ;
169- localApi . addDecorator ( fn => `aa- ${ fn ( ) } ` ) ;
169+ localApi . addDecorator ( fn => ( { template : `<div>aa ${ fn ( ) . template } </div>` } ) ) ;
170170
171- localApi . add ( 'storyName' , ( { kind, story } ) => ` ${ kind } -${ story } ` ) ;
171+ localApi . add ( 'storyName' , ( { kind, story } ) => ( { template : `<p> ${ kind } -${ story } </p>` } ) ) ;
172172
173173 const kind = 'dfdfd' ;
174174 const story = 'ef349ff' ;
175175
176176 const result = storyStore . stories [ 0 ] . fn ( { kind, story } ) ;
177- expect ( result ) . toBe ( `aa- ${ kind } -${ story } ` ) ;
177+ expect ( result . template ) . toBe ( `<div>aa<p> ${ kind } -${ story } </p></div> ` ) ;
178178 } ) ;
179179
180180 it ( 'should have access to the context' , ( ) => {
181181 const storyStore = new StoryStore ( ) ;
182182 const api = new ClientAPI ( { storyStore } ) ;
183183 const localApi = api . storiesOf ( 'none' ) ;
184- localApi . addDecorator ( ( fn , { kind, story } ) => ` ${ kind } -${ story } -${ fn ( ) } ` ) ;
184+ localApi . addDecorator ( ( fn , { kind, story } ) => ( { template : `<div> ${ kind } -${ story } -${ fn ( ) . template } </div>` } ) ) ;
185185
186- localApi . add ( 'storyName' , ( ) => 'Hello' ) ;
186+ localApi . add ( 'storyName' , ( ) => ( { template : '<p>hello</p>' } ) ) ;
187187
188188 const kind = 'dfdfd' ;
189189 const story = 'ef349ff' ;
190190
191191 const result = storyStore . stories [ 0 ] . fn ( { kind, story } ) ;
192- expect ( result ) . toBe ( `${ kind } -${ story } -Hello ` ) ;
192+ expect ( result . template ) . toBe ( `<div> ${ kind } -${ story } -<p>hello</p></div> ` ) ;
193193 } ) ;
194194 } ) ;
195195
0 commit comments