@@ -63,7 +63,7 @@ describe('AccountsOauth', () => {
63
63
}
64
64
} ) ;
65
65
66
- it ( ' should call provider\ 's authenticate method in order to get the user itself' , async ( ) => {
66
+ it ( " should call provider's authenticate method in order to get the user itself" , async ( ) => {
67
67
const authSpy = jest . fn ( ( ) => ( {
68
68
id : '312312' ,
69
69
name : 'Mr. Anderson' ,
@@ -83,7 +83,7 @@ describe('AccountsOauth', () => {
83
83
84
84
expect ( authSpy ) . toBeCalledWith ( params ) ;
85
85
} ) ;
86
-
86
+
87
87
it ( 'should find a user by service id or email' , async ( ) => {
88
88
const authSpy = jest . fn ( ( ) => ( {
89
89
id : '312312' ,
@@ -133,7 +133,7 @@ describe('AccountsOauth', () => {
133
133
id : '34123' ,
134
134
email : user2 . email ,
135
135
} ) ) ,
136
- }
136
+ } ;
137
137
oauth . setStore ( store ) ;
138
138
139
139
const params = {
@@ -149,55 +149,58 @@ describe('AccountsOauth', () => {
149
149
expect ( store . setService ) . toBeCalledWith ( '34123' , 'facebook' , user2 ) ;
150
150
} ) ;
151
151
} ) ;
152
-
153
- it ( 'should update the user\'s profile if logged in after change in profile' , async ( ) => {
154
- const userChanged = {
155
- id : '312312' ,
156
- name : 'Mr. Anderson' ,
157
-
158
- profile : {
159
- gender : 'other' ,
160
- } ,
161
- } ;
162
- const authSpy = jest . fn ( ( ) => userChanged ) ;
163
- const oauth = new AccountsOauth ( {
164
- facebook : {
165
- authenticate : authSpy ,
166
- } ,
167
- } ) ;
168
- oauth . setStore ( mockStore ) ;
169
-
170
- const params = {
171
- provider : 'facebook' ,
172
- } ;
173
- await oauth . authenticate ( params ) ;
174
152
175
- expect ( authSpy ) . toBeCalledWith ( params ) ;
176
- expect ( mockStore . findUserByServiceId ) . toBeCalledWith ( 'facebook' , '312312' ) ;
177
- expect ( mockStore . setProfile ) . toBeCalledWith ( user . id , userChanged . profile ) ;
178
- expect ( mockStore . setService ) . toBeCalledWith ( user . id , 'facebook' , userChanged ) ;
179
- } ) ;
180
- } ) ;
181
-
182
- describe ( 'unlink' , ( ) => {
153
+ it ( "should update the user's profile if logged in after change in profile" , async ( ) => {
154
+ const userChanged = {
155
+ id : '312312' ,
156
+ name : 'Mr. Anderson' ,
157
+
158
+ profile : {
159
+ gender : 'other' ,
160
+ } ,
161
+ } ;
162
+ const authSpy = jest . fn ( ( ) => userChanged ) ;
183
163
const oauth = new AccountsOauth ( {
184
164
facebook : {
185
- authenticate : jest . fn ( ) ,
165
+ authenticate : authSpy ,
186
166
} ,
187
167
} ) ;
188
168
oauth . setStore ( mockStore ) ;
189
-
190
- it ( 'should throw if given wrong provider' , async ( ) => {
191
- try {
192
- await oauth . unlink ( '1' , 'twitter' ) ;
193
- } catch ( e ) {
194
- expect ( e . message ) . toBe ( 'Invalid provider' ) ;
195
- }
196
- } ) ;
197
-
198
- it ( 'should unset data of oauth provider' , async ( ) => {
199
- await oauth . unlink ( '1' , 'facebook' ) ;
200
- expect ( mockStore . setService ) . toBeCalledWith ( '1' , 'facebook' , null ) ;
201
- } ) ;
169
+
170
+ const params = {
171
+ provider : 'facebook' ,
172
+ } ;
173
+ await oauth . authenticate ( params ) ;
174
+
175
+ expect ( authSpy ) . toBeCalledWith ( params ) ;
176
+ expect ( mockStore . findUserByServiceId ) . toBeCalledWith ( 'facebook' , '312312' ) ;
177
+ expect ( mockStore . setProfile ) . toBeCalledWith ( user . id , userChanged . profile ) ;
178
+ expect ( mockStore . setService ) . toBeCalledWith (
179
+ user . id ,
180
+ 'facebook' ,
181
+ userChanged
182
+ ) ;
183
+ } ) ;
184
+ } ) ;
185
+
186
+ describe ( 'unlink' , ( ) => {
187
+ const oauth = new AccountsOauth ( {
188
+ facebook : {
189
+ authenticate : jest . fn ( ) ,
190
+ } ,
191
+ } ) ;
192
+ oauth . setStore ( mockStore ) ;
193
+
194
+ it ( 'should throw if given wrong provider' , async ( ) => {
195
+ try {
196
+ await oauth . unlink ( '1' , 'twitter' ) ;
197
+ } catch ( e ) {
198
+ expect ( e . message ) . toBe ( 'Invalid provider' ) ;
199
+ }
200
+ } ) ;
201
+
202
+ it ( 'should unset data of oauth provider' , async ( ) => {
203
+ await oauth . unlink ( '1' , 'facebook' ) ;
204
+ expect ( mockStore . setService ) . toBeCalledWith ( '1' , 'facebook' , null ) ;
202
205
} ) ;
203
206
} ) ;
0 commit comments