11import { expect , test } from '@oclif/test'
2- import * as cp from 'child_process' ;
3- import * as path from 'path' ;
4-
5- let pkg = require ( '../../package.json' ) ;
6- let assert = require ( 'assert' ) ;
7- let sv = require ( 'semver' ) ;
82
93describe ( 'chatdown' , ( ) => {
104
@@ -15,74 +9,4 @@ describe('chatdown', () => {
159 expect ( ctx . stdout ) . to . contain ( 'Converts chat dialog files in <filename>.' )
1610 } )
1711
18- it ( 'should accept data as a pipe and output the results' , done => {
19- cp . exec ( `(echo user=Joe && echo bot=LuliBot && echo LuliBot: hello! && echo joe:can I get some help?) | node ./bin/run chatdown` , ( error , stdout ) => {
20- assert . doesNotThrow ( ( ) => JSON . parse ( stdout ) ) ;
21- done ( ) ;
22- } ) ;
23- } ) ;
24-
25- test
26- . stdout ( )
27- . command ( [ 'chatdown' ] )
28- . it ( 'should print the help contents when no input is passed' , ctx => {
29- expect ( ctx . stdout ) . to . contain ( 'Converts chat dialog files in <filename>.' )
30- } )
31-
32- it ( 'should throw when a malformed config options is encountered in the input' , done => {
33- cp . exec ( `echo bot=LuliBot=joe | node ./bin/run chatdown` , ( error , stdout , stderr ) => {
34- assert ( stderr . trim ( ) . indexOf ( 'Malformed configurations options detected. Options must be in the format optionName=optionValue' ) >= 0 ) ;
35- done ( ) ;
36- } ) ;
37- } ) ;
38-
39- it ( 'should generate static based timestamps when --static is passed as an argument' , done => {
40- cp . exec ( `(echo user=Joe && [ConversationUpdate=MembersAdded=Joe]) | node ./bin/run chatdown --static` , ( error , stdout ) => {
41- assert . doesNotThrow ( ( ) => JSON . parse ( stdout ) ) ;
42- done ( ) ;
43- } ) ;
44- } ) ;
45-
46- it ( 'should read from file when chat file is passed as an argument' , done => {
47- cp . exec ( `node ./bin/run chatdown --in "./test/utils/cli.sample.chat"` , ( error , stdout ) => {
48- assert . doesNotThrow ( ( ) => JSON . parse ( stdout ) ) ;
49- done ( ) ;
50- } ) ;
51- } ) ;
52-
53- it ( 'should process all files when a glob is passed in with the -i argument, and the -o is passed in for the output directory' , done => {
54- cp . exec ( `node ./bin/run chatdown -i "./test/utils/*.sample.chat" -o ./` , ( error , stdout , stderr ) => {
55- assert ( stdout . includes ( 'Successfully wrote' ) ) ;
56- done ( ) ;
57- } ) ;
58- } ) ;
59-
60- it ( 'should process all files when a glob is passed in with the -i argument' , done => {
61- cp . exec ( `node ./bin/run chatdown -i "./test/utils/*.sample.chat"` , ( error , stdout , stderr ) => {
62- assert ( stdout . includes ( 'Successfully wrote' ) ) ;
63- done ( ) ;
64- } ) ;
65- } ) ;
66-
67- it ( 'should not prefix [chatdown] to stdout when --prefix is not passed as an argument' , done => {
68- cp . exec ( `echo bot=LuliBot | node ./bin/run chatdown` , ( error , stdout , stderr ) => {
69- assert . notEqual ( stdout . startsWith ( `[${ pkg . name } ]` ) , `It should not show the tag '[${ pkg . name } ]' when not using the argument --prefix` ) ;
70- done ( ) ;
71- } ) ;
72- } ) ;
73-
74- it ( 'should prefix [chatdown] to stderr when --prefix is passed as an argument' , done => {
75- cp . exec ( `echo bot=LuliBot | node ./bin/run chatdown --prefix` , ( error , stdout , stderr ) => {
76- assert ( stdout . startsWith ( `[${ pkg . name } ]` ) , `It should show the tag '[${ pkg . name } ]' when using the argument --prefix` ) ;
77- done ( ) ;
78- } ) ;
79- } ) ;
80-
81- it ( 'throw error if invalid path in argument' , done => {
82- cp . exec ( `node ./bin/run chatdown --in 'aaaaa'` , ( error , stdout , stderr ) => {
83- assert ( stderr . includes ( 'no such file or directory' ) || stderr . includes ( 'error' ) ) ;
84- done ( ) ;
85- } ) ;
86- } ) ;
87-
8812} )
0 commit comments