1 | import test from 'tape'
|
2 | import {
|
3 | initProcess,
|
4 | logProcess,
|
5 | submit,
|
6 | out,
|
7 | INIT_PROCESS,
|
8 | LOG_PROCESS,
|
9 | SUBMIT,
|
10 | OUT
|
11 | } from '../src/actions'
|
12 |
|
13 | test('actions', (t) => {
|
14 | let id = 0
|
15 |
|
16 | t.test('should create an action to init a process', (subt) => {
|
17 | const command = 'test'
|
18 | const expectedAction = {
|
19 | type: INIT_PROCESS,
|
20 | payload: {
|
21 | id,
|
22 | argv: command
|
23 | }
|
24 | }
|
25 | subt.deepEquals(initProcess(id, command), expectedAction)
|
26 | subt.end()
|
27 | })
|
28 |
|
29 | t.test('should create an action to log to a process', (subt) => {
|
30 | const output = 'message'
|
31 | const expectedAction = {
|
32 | type: LOG_PROCESS,
|
33 | payload: {
|
34 | id,
|
35 | output
|
36 | }
|
37 | }
|
38 | subt.deepEquals(logProcess(id, output), expectedAction)
|
39 | subt.end()
|
40 | })
|
41 |
|
42 | t.test('should create an action to submit text', (subt) => {
|
43 | const text = 'this is a test'
|
44 | const payload = ['this', 'is', 'a', 'test']
|
45 | const expectedAction = {
|
46 | payload,
|
47 | type: SUBMIT
|
48 | }
|
49 | subt.deepEquals(submit(text), expectedAction)
|
50 | subt.end()
|
51 | })
|
52 |
|
53 | t.test('should create an action for an out message', (subt) => {
|
54 | const payload = 'message'
|
55 | const expectedAction = {
|
56 | payload,
|
57 | type: OUT
|
58 | }
|
59 | subt.deepEquals(out('message'), expectedAction)
|
60 | subt.end()
|
61 | })
|
62 | })
|