1
1
const command = require ( '../../src/commands/ls' )
2
2
const validators = require ( '../../src/commands/helpers/validators' )
3
3
4
- describe ( 'qyarn jest ' , ( ) => {
4
+ describe ( 'ls ' , ( ) => {
5
5
let apps
6
6
7
7
beforeEach ( ( ) => {
8
8
require ( '../_helpers/pgb' ) ( { commands : [ 'ls' ] } )
9
9
apps = { apps : [
10
- { id : 1 , status : { ios : 'error' , android : 'skip' , winphone : 'pending' } , last_build : '4 march 1994' , foo : 'bar' , zig : null } ,
10
+ { id : 1 , title : '123456789012345678901234567890' , status : { ios : 'error' , android : 'skip' , winphone : 'pending' } , last_build : '4 march 1994' , foo : 'bar' , zig : null } ,
11
11
{ id : 12 , status : { ios : 'error' , android : 'unknown' , winphone : 'complete' } , foo : { a : 12 } }
12
12
] }
13
13
pgb . api . getApps = jest . fn ( ( ) => Promise . resolve ( apps ) )
14
+ process . stdout . columns = 10
14
15
} )
15
16
16
17
afterAll ( ( ) => {
17
18
delete global . pgb
19
+ process . stdout . columns = 10
18
20
} )
19
21
20
22
test ( 'should validate' , ( ) => {
@@ -26,6 +28,31 @@ describe('qyarn jest', () => {
26
28
} )
27
29
28
30
test ( 'should print apps details' , ( ) => {
31
+ return Promise . resolve ( )
32
+ . then ( command )
33
+ . then ( ( ) => {
34
+ let call = pgb . print . mock . calls [ 0 ]
35
+ expect ( call [ 0 ] . pretty ) . toMatch ( / A p p I d [ ^ ] * 1 [ ^ ] * 1 2 3 4 5 6 7 8 9 0 1 2 \. \. \. [ ^ ] * F A I L E D [ ^ ] * S K I P P E D [ ^ ] * B U I L D I N G [ ^ ] * 1 9 9 4 - 0 3 - 0 4 [ ^ ] * 1 2 [ ^ ] * F A I L E D [ ^ ] * B U I L D I N G [ ^ ] * S U C C E S S / )
36
+ expect ( call [ 0 ] . json ) . toEqual ( apps )
37
+ expect ( call [ 0 ] . bare ) . toEqual ( '1\n12' )
38
+ expect ( pgb . api . getApps ) . toHaveBeenCalled ( )
39
+ } )
40
+ } )
41
+
42
+ test ( 'should print apps details even when not stdout.tty' , ( ) => {
43
+ process . stdout . columns = undefined
44
+ return Promise . resolve ( )
45
+ . then ( command )
46
+ . then ( ( ) => {
47
+ let call = pgb . print . mock . calls [ 0 ]
48
+ expect ( call [ 0 ] . pretty ) . toMatch ( / A p p I d [ ^ ] * 1 [ ^ ] * 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 [ ^ ] * F A I L E D [ ^ ] * S K I P P E D [ ^ ] * B U I L D I N G [ ^ ] * 1 9 9 4 - 0 3 - 0 4 [ ^ ] * 1 2 [ ^ ] * F A I L E D [ ^ ] * B U I L D I N G [ ^ ] * S U C C E S S / )
49
+ expect ( call [ 0 ] . json ) . toEqual ( apps )
50
+ expect ( call [ 0 ] . bare ) . toEqual ( '1\n12' )
51
+ expect ( pgb . api . getApps ) . toHaveBeenCalled ( )
52
+ } )
53
+ } )
54
+
55
+ test ( 'should truncate properly if no tty' , ( ) => {
29
56
return Promise . resolve ( )
30
57
. then ( command )
31
58
. then ( ( ) => {
0 commit comments