File tree Expand file tree Collapse file tree 4 files changed +19
-11
lines changed
Expand file tree Collapse file tree 4 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
3+ import { tick } from 'svelte'
34import { BehaviorSubject , Subject } from 'rxjs'
45import { location , replace } from 'svelte-spa-router'
56import { albums } from './albums'
6- import { playlists } from './playlists'
77import { tracks } from './track-queue'
8- import { tick } from 'svelte '
8+ import { lastInvokation } from '../utils '
99
1010const steps = [
1111 {
@@ -40,7 +40,8 @@ const steps = [
4040 annotation : {
4141 left : '15%'
4242 } ,
43- listen : ( ) => awaitsEvent ( playlists , playlists => playlists . length > 0 )
43+ listen : ( ) =>
44+ awaitsEvent ( lastInvokation , ( { invoked } ) => invoked === 'playlists.save' )
4445 } ,
4546 {
4647 anchorId : 'to-playlists' ,
Original file line number Diff line number Diff line change @@ -101,13 +101,7 @@ describe('tutorial store', () => {
101101 } )
102102
103103 it ( 'goes to sixth step when creating a playlist' , async ( ) => {
104- mockInvoke . mockResolvedValueOnce ( {
105- results : [ { } ] ,
106- total : 1 ,
107- size : 1 ,
108- from : 0
109- } )
110- playlists . list ( )
104+ playlists . save ( { name : 'my playlist' , trackIds : [ 123456 ] } )
111105 await sleep ( )
112106 expect ( get ( current ) ) . toEqual (
113107 expect . objectContaining ( {
Original file line number Diff line number Diff line change 22
33// note: do not destructure, as it makes it harder to mock in Storybook
44const electron = require ( 'electron' )
5+ import { BehaviorSubject } from 'rxjs'
6+
7+ const lastInvokation$ = new BehaviorSubject ( )
8+
9+ export const lastInvokation = lastInvokation$ . asObservable ( )
510
611export async function invoke ( invoked , ...args ) {
12+ lastInvokation$ . next ( { invoked, args } )
713 return electron . ipcRenderer . invoke ( 'remote' , ...invoked . split ( '.' ) , ...args )
814}
Original file line number Diff line number Diff line change 11'use strict'
22
3+ import { get } from 'svelte/store'
34import faker from 'faker'
4- import { invoke } from './invoke'
5+ import { invoke , lastInvokation } from './invoke'
56import electron from 'electron'
7+ import { sleep } from '../tests'
68
79jest . mock ( 'electron' , ( ) => ( {
810 ipcRenderer : {
@@ -29,5 +31,10 @@ describe('invoke', () => {
2931 arg2
3032 )
3133 expect ( electron . ipcRenderer . invoke ) . toHaveBeenCalledTimes ( 1 )
34+ await sleep ( )
35+ expect ( get ( lastInvokation ) ) . toEqual ( {
36+ invoked : 'dialog.showOpenDialog' ,
37+ args : [ arg1 , arg2 ]
38+ } )
3239 } )
3340} )
You can’t perform that action at this time.
0 commit comments