@@ -22,15 +22,13 @@ const fakeRuntime = {
2222describe ( 'CompassShell' , function ( ) {
2323 context ( 'when rendered' , function ( ) {
2424 let wrapper ;
25- let emitShellOpenedSpy ;
2625
2726 beforeEach ( function ( ) {
28- emitShellOpenedSpy = sinon . spy ( ) ;
29-
3027 wrapper = mount (
3128 < CompassShell
29+ initialHistory = { [ ] }
30+ onHistoryChange = { ( ) => undefined }
3231 runtime = { fakeRuntime }
33- emitShellPluginOpened = { emitShellOpenedSpy }
3432 enableShell
3533 />
3634 ) ;
@@ -49,23 +47,19 @@ describe('CompassShell', function () {
4947 getComputedStyle ( shellDomNode ) . getPropertyValue ( 'display' ) ;
5048 expect ( shellDisplayStyle ) . to . equal ( 'none' ) ;
5149 } ) ;
52-
53- context ( 'when is it expanded' , function ( ) {
54- it ( 'calls the function prop emitShellPluginOpened' , function ( ) {
55- expect ( emitShellOpenedSpy . calledOnce ) . to . equal ( false ) ;
56-
57- wrapper . setState ( { height : 300 } ) ;
58- wrapper . update ( ) ;
59-
60- expect ( emitShellOpenedSpy . calledOnce ) . to . equal ( true ) ;
61- } ) ;
62- } ) ;
6350 } ) ;
6451
6552 context ( 'when rendered expanded' , function ( ) {
6653 context ( 'when runtime property is not present' , function ( ) {
6754 it ( 'does not render a shell if runtime is null' , function ( ) {
68- const wrapper = mount ( < CompassShell runtime = { null } enableShell /> ) ;
55+ const wrapper = mount (
56+ < CompassShell
57+ initialHistory = { [ ] }
58+ onHistoryChange = { ( ) => undefined }
59+ runtime = { null }
60+ enableShell
61+ />
62+ ) ;
6963 try {
7064 wrapper . setState ( { height : 300 } ) ;
7165 wrapper . update ( ) ;
@@ -82,8 +76,9 @@ describe('CompassShell', function () {
8276 beforeEach ( function ( ) {
8377 wrapper = mount (
8478 < CompassShell
79+ initialHistory = { [ ] }
80+ onHistoryChange = { ( ) => undefined }
8581 runtime = { fakeRuntime }
86- emitShellPluginOpened = { ( ) => { } }
8782 enableShell
8883 />
8984 ) ;
@@ -128,8 +123,9 @@ describe('CompassShell', function () {
128123 it ( 'renders the inital output' , function ( ) {
129124 const wrapper = mount (
130125 < CompassShell
126+ initialHistory = { [ ] }
127+ onHistoryChange = { ( ) => undefined }
131128 runtime = { fakeRuntime }
132- emitShellPluginOpened = { ( ) => { } }
133129 shellOutput = { [
134130 {
135131 type : 'output' ,
@@ -159,7 +155,12 @@ describe('CompassShell', function () {
159155 context ( 'when historyStorage is not present' , function ( ) {
160156 it ( 'passes an empty history to the Shell' , function ( ) {
161157 const wrapper = shallow (
162- < CompassShell runtime = { fakeRuntime } enableShell />
158+ < CompassShell
159+ initialHistory = { [ ] }
160+ onHistoryChange = { ( ) => undefined }
161+ runtime = { fakeRuntime }
162+ enableShell
163+ />
163164 ) ;
164165
165166 expect ( wrapper . find ( Shell ) . prop ( 'initialHistory' ) ) . to . deep . equal ( [ ] ) ;
@@ -174,8 +175,9 @@ describe('CompassShell', function () {
174175 beforeEach ( function ( ) {
175176 wrapper = mount (
176177 < CompassShell
178+ initialHistory = { [ ] }
179+ onHistoryChange = { ( ) => undefined }
177180 runtime = { fakeRuntime }
178- emitShellPluginOpened = { ( ) => { } }
179181 enableShell
180182 />
181183 ) ;
@@ -221,22 +223,14 @@ describe('CompassShell', function () {
221223 } ) ;
222224
223225 context ( 'when historyStorage is present' , function ( ) {
224- let fakeStorage ;
225-
226- beforeEach ( function ( ) {
227- fakeStorage = {
228- load : sinon . spy ( ( ) => Promise . resolve ( [ ] ) ) ,
229- save : sinon . spy ( ( ) => Promise . resolve ( ) ) ,
230- } ;
231- } ) ;
226+ const history = [ 'line1' ] ;
232227
233228 it ( 'passes the loaded history as initialHistory to Shell' , async function ( ) {
234- fakeStorage . load = sinon . spy ( ( ) => Promise . resolve ( [ 'line1' ] ) ) ;
235-
236229 const wrapper = shallow (
237230 < CompassShell
238231 runtime = { { } as any }
239- historyStorage = { fakeStorage }
232+ initialHistory = { history }
233+ onHistoryChange = { ( ) => undefined }
240234 enableShell
241235 />
242236 ) ;
@@ -251,10 +245,13 @@ describe('CompassShell', function () {
251245 } ) ;
252246
253247 it ( 'saves the history when history changes' , async function ( ) {
248+ const changeSpy = sinon . spy ( ) ;
249+
254250 const wrapper = shallow (
255251 < CompassShell
256252 runtime = { { } as any }
257- historyStorage = { fakeStorage }
253+ initialHistory = { [ ] }
254+ onHistoryChange = { changeSpy }
258255 enableShell
259256 />
260257 ) ;
@@ -264,7 +261,7 @@ describe('CompassShell', function () {
264261 const onHistoryChanged = wrapper . find ( Shell ) . prop ( 'onHistoryChanged' ) ;
265262 onHistoryChanged ( [ 'line1' ] ) ;
266263
267- expect ( fakeStorage . save . calledWith ( [ 'line1' ] ) ) . to . equal ( true ) ;
264+ expect ( changeSpy ) . to . have . been . calledOnceWith ( [ 'line1' ] ) ;
268265
269266 wrapper . unmount ( ) ;
270267 } ) ;
@@ -291,22 +288,20 @@ describe('CompassShell', function () {
291288 } ) ;
292289
293290 context ( 'resize actions' , function ( ) {
294- let onOpenShellSpy ;
295291 let wrapper ;
296292
297293 beforeEach ( function ( ) {
298- onOpenShellSpy = sinon . spy ( ) ;
299294 wrapper = mount (
300295 < CompassShell
296+ initialHistory = { [ ] }
297+ onHistoryChange = { ( ) => undefined }
301298 runtime = { fakeRuntime }
302- emitShellPluginOpened = { onOpenShellSpy }
303299 enableShell
304300 />
305301 ) ;
306302 } ) ;
307303 afterEach ( function ( ) {
308304 wrapper . unmount ( ) ;
309- onOpenShellSpy = null ;
310305 wrapper = null ;
311306 } ) ;
312307
@@ -379,10 +374,6 @@ describe('CompassShell', function () {
379374 expect ( shellDisplayStyle ) . to . equal ( 'none' ) ;
380375 } ) ;
381376
382- it ( 'does not calls the function prop emitShellPluginOpened' , function ( ) {
383- expect ( onOpenShellSpy . called ) . to . equal ( false ) ;
384- } ) ;
385-
386377 context ( 'when it hits the resize threshold' , function ( ) {
387378 beforeEach ( function ( ) {
388379 wrapper . setState ( { height : 151 } ) ;
@@ -395,10 +386,6 @@ describe('CompassShell', function () {
395386 ) . to . equal ( 151 ) ;
396387 expect ( wrapper . state ( 'height' ) ) . to . equal ( 151 ) ;
397388 } ) ;
398-
399- it ( 'calls the function prop emitShellPluginOpened' , function ( ) {
400- expect ( onOpenShellSpy . calledOnce ) . to . equal ( true ) ;
401- } ) ;
402389 } ) ;
403390 } ) ;
404391 } ) ;
0 commit comments