@@ -34,18 +34,37 @@ describe('Creates and removes channels (e2e)', () => {
34
34
} ) ;
35
35
36
36
it ( 'should create channels' , async ( ) => {
37
+ let channelCreatedEventEmitted = false ;
38
+ client . once ( 'channelCreate' , ( channel : Channel ) => {
39
+ expect ( channel . name ) . toEqual ( 'sub1' ) ;
40
+ channelCreatedEventEmitted = true ;
41
+ } ) ;
42
+
37
43
const channel = client . user ?. channel as Channel ;
38
44
expect ( channel ) . toBeTruthy ( ) ;
39
45
const sub1 = await channel . createSubChannel ( 'sub1' ) ;
40
46
expect ( sub1 . parent ) . toEqual ( channel . id ) ;
47
+ expect ( channelCreatedEventEmitted ) . toBe ( true ) ;
41
48
42
49
const sub2 = await sub1 . createSubChannel ( 'sub2' ) ;
43
50
expect ( sub2 . parent ) . toEqual ( sub1 . id ) ;
44
51
} ) ;
45
52
46
53
it ( 'should remove channels' , async ( ) => {
47
- const channel = client . channels . byName ( 'sub1' ) ;
48
- await channel ?. remove ( ) ;
54
+ let channelRemoveEventEmitted = false ;
55
+
56
+ client . once ( 'channelRemove' , ( channel : Channel ) => {
57
+ expect ( channel . name ) . toEqual ( 'sub2' ) ;
58
+ channelRemoveEventEmitted = true ;
59
+ } ) ;
60
+
61
+ const sub2 = client . channels . byName ( 'sub2' ) ;
62
+ await sub2 ?. remove ( ) ;
63
+ expect ( client . channels . byName ( 'sub2' ) ) . toBe ( undefined ) ;
64
+ expect ( channelRemoveEventEmitted ) . toBe ( true ) ;
65
+
66
+ const sub1 = client . channels . byName ( 'sub1' ) ;
67
+ await sub1 ?. remove ( ) ;
49
68
expect ( client . channels . byName ( 'sub1' ) ) . toBe ( undefined ) ;
50
69
} ) ;
51
70
} ) ;
0 commit comments