@@ -27,6 +27,7 @@ import {
2727 NOT_SUPPORTED_URL_PARAM_COMMAND
2828} from './editorDuck'
2929import { APP_START , URL_ARGUMENTS_CHANGE } from '../app/appDuck'
30+ import { COMMAND_QUEUED , executeCommand } from '../commands/commandsDuck'
3031
3132describe ( 'editorDuck Epics' , ( ) => {
3233 let store
@@ -47,19 +48,39 @@ describe('editorDuck Epics', () => {
4748 bus . reset ( )
4849 store . clearActions ( )
4950 } )
50- test ( 'Sends a SET_CONTENT event on initial url arguments ' , done => {
51+ test ( 'Sends a COMMAND_QUEUED event if cmd is "play" ' , done => {
5152 const cmd = 'play'
5253 const arg = 'test-guide'
5354 const action = {
5455 type : APP_START ,
5556 url : `http://url.com?cmd=${ cmd } &arg=${ arg } `
5657 }
5758
59+ bus . take ( COMMAND_QUEUED , ( ) => {
60+ // Then
61+ expect ( store . getActions ( ) ) . toEqual ( [
62+ action ,
63+ executeCommand ( `:${ cmd } ${ arg } ` )
64+ ] )
65+ done ( )
66+ } )
67+
68+ // When
69+ store . dispatch ( action )
70+ } )
71+ test ( 'Sends a SET_CONTENT event on initial url arguments' , done => {
72+ const cmd = 'edit'
73+ const arg = 'RETURN 1'
74+ const action = {
75+ type : APP_START ,
76+ url : `http://url.com?cmd=${ cmd } &arg=${ arg } `
77+ }
78+
5879 bus . take ( SET_CONTENT , currentAction => {
5980 // Then
6081 expect ( store . getActions ( ) ) . toEqual ( [
6182 action ,
62- { type : SET_CONTENT , message : `: ${ cmd } ${ arg } ` }
83+ { type : SET_CONTENT , message : arg }
6384 ] )
6485 done ( )
6586 } )
@@ -68,8 +89,8 @@ describe('editorDuck Epics', () => {
6889 store . dispatch ( action )
6990 } )
7091 test ( 'Sends a SET_CONTENT event on url arguments change' , done => {
71- const cmd = 'play '
72- const arg = 'test-guide '
92+ const cmd = 'edit '
93+ const arg = 'RETURN 1 '
7394 const action = {
7495 type : URL_ARGUMENTS_CHANGE ,
7596 url : `?cmd=${ cmd } &arg=${ arg } `
@@ -79,7 +100,7 @@ describe('editorDuck Epics', () => {
79100 // Then
80101 expect ( store . getActions ( ) ) . toEqual ( [
81102 action ,
82- { type : SET_CONTENT , message : `: ${ cmd } ${ arg } ` }
103+ { type : SET_CONTENT , message : arg }
83104 ] )
84105 done ( )
85106 } )
0 commit comments