forked from artwells/meteor-accounts-guest
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaccounts-anonymous-client-tests.js
31 lines (30 loc) · 1.03 KB
/
accounts-anonymous-client-tests.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
"use strict";
/* globals AccountsAnonymous */
Tinytest.addAsync('AccountsAnonymous - login()', function (test, onComplete) {
Meteor.logout(function (err) {
test.isUndefined(err);
test.isNull(Meteor.userId(), 'Logged out user should be null');
AccountsAnonymous.login(function (err) {
test.isUndefined(err);
var firstUserId = Meteor.userId();
test.isNotNull(firstUserId, 'Logged in user should not be null');
AccountsAnonymous.login(function (err) {
test.instanceOf(err, Meteor.Error);
test.equal(err.error, AccountsAnonymous._ALREADY_LOGGED_IN_ERROR);
var secondUserId = Meteor.userId();
test.equal(secondUserId, firstUserId);
Meteor.logout(function (err) {
test.isUndefined(err);
test.isNull(Meteor.userId(), 'Logged out user should be null');
AccountsAnonymous.login(function (err) {
test.isUndefined(err);
var thirdUserId = Meteor.userId();
test.isNotNull(thirdUserId);
test.notEqual(thirdUserId, secondUserId);
onComplete();
});
});
});
});
});
});