@@ -31,8 +31,8 @@ afterAll(async () => {
31
31
await db . destroy ( ) ;
32
32
} ) ;
33
33
34
- describe ( 'getSubscribedUsers ' , ( ) => {
35
- test ( 'returns seen users that did not unsubscribe ' , async ( ) => {
34
+ describe ( 'User subscription read model ' , ( ) => {
35
+ test ( 'returns subscribed and unsubscribed users ' , async ( ) => {
36
36
const user1 = await userStore . insert ( {
37
37
38
38
name : 'User One' ,
@@ -43,11 +43,13 @@ describe('getSubscribedUsers', () => {
43
43
44
44
name : 'User Two' ,
45
45
} ) ;
46
+ // never seen
46
47
const user3 = await userStore . insert ( {
47
48
48
49
name : 'User Three' ,
49
50
} ) ;
50
51
52
+ // unsubscribe
51
53
await userUnsubscribeStore . insert ( {
52
54
userId : user2 . id ,
53
55
subscription,
@@ -62,6 +64,14 @@ describe('getSubscribedUsers', () => {
62
64
{ email :
'[email protected] ' , name :
'User One' } ,
63
65
] ) ,
64
66
) ;
67
+
68
+ const unsubscribers =
69
+ await userSubscriptionsReadModel . getUnsubscribedUsers ( subscription ) ;
70
+ expect ( unsubscribers ) . toEqual (
71
+ expect . arrayContaining ( [
72
+ { email :
'[email protected] ' , name :
'User Two' } ,
73
+ ] ) ,
74
+ ) ;
65
75
} ) ;
66
76
67
77
test ( 'reflects changes after unsubscribe and resubscribe' , async ( ) => {
@@ -120,8 +130,8 @@ describe('getSubscribedUsers', () => {
120
130
} ) ;
121
131
} ) ;
122
132
123
- describe ( 'getUserSubscriptions ' , ( ) => {
124
- test ( 'returns all subscriptions if user has not unsubscribed' , async ( ) => {
133
+ describe ( 'User subscription read model ' , ( ) => {
134
+ test ( 'returns all user subscriptions if user has not unsubscribed' , async ( ) => {
125
135
const user = await userStore . insert ( {
126
136
127
137
name : 'User Four' ,
0 commit comments