-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy pathverifyUserEmails.spec.js
66 lines (53 loc) · 1.61 KB
/
verifyUserEmails.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
const { getAuthForSessionToken } = require('../lib/Auth');
const Config = require('../lib/Config');
describe('verifyUserEmails with Auth Context', () => {
let user;
let config;
beforeEach(async (done) => {
await reconfigureServer({
verifyUserEmails: jasmine.createSpy('verifyUserEmails'),
});
user = new Parse.User();
await user.signUp({
username: 'testuser',
password: 'securepassword',
email: '[email protected]',
});
config = Config.get('test');
done();
});
it('should call verifyUserEmails with correct auth context on signup', async (done) => {
const sessionToken = user.getSessionToken();
expect(sessionToken).toBeDefined();
await getAuthForSessionToken({
sessionToken,
config,
});
expect(config.verifyUserEmails).toHaveBeenCalledWith({
action: 'signup',
authProvider: 'password',
});
done();
});
it('should call verifyUserEmails with correct auth context on login', async (done) => {
await Parse.User.logIn('testuser', 'securepassword');
expect(config.verifyUserEmails).toHaveBeenCalledWith({
action: 'login',
authProvider: 'password',
});
done();
});
it('should call verifyUserEmails with correct provider for social login', async (done) => {
const socialAuthData = {
id: '1234567890',
access_token: 'mockAccessToken',
};
await Parse.User.logInWith('facebook', { authData: socialAuthData });
expect(config.verifyUserEmails).toHaveBeenCalledWith({
action: 'login',
authProvider: 'facebook',
});
done();
});
});