Skip to content

Commit ee34a79

Browse files
committed
Ensure a fresh user is used for each test
1 parent b13b1ba commit ee34a79

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

spec/ParseAPI.spec.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ describe('miscellaneous', function() {
4444
expect(typeof obj.id).toBe('string');
4545
expect(typeof obj.createdAt.toGMTString()).toBe('string');
4646
done();
47-
}, error => {
48-
fail(JSON.stringify(error));
49-
done();
50-
});
47+
}, done.fail);
5148
});
5249

5350
it('get a TestObject', function(done) {
@@ -67,13 +64,13 @@ describe('miscellaneous', function() {
6764
expect(data.getSessionToken()).not.toBeUndefined();
6865
expect(data.get('password')).toBeUndefined();
6966
done();
70-
}, error => {
71-
fail(JSON.stringify(error));
72-
done();
73-
});
67+
}, done.fail);
7468
});
7569

76-
it('fail to create a duplicate username', done => {
70+
it('fail to create a duplicate username', async done => {
71+
try {
72+
await Parse.User.logOut();
73+
} catch(e) { /* ignore */ }
7774
let numCreated = 0;
7875
let numFailed = 0;
7976
const p1 = createTestUser();
@@ -101,11 +98,19 @@ describe('miscellaneous', function() {
10198
fail('one of the users should not have been created');
10299
done();
103100
})
104-
.catch(done);
101+
.catch(() => {})
102+
.finally(async () => {
103+
try {
104+
await Parse.User.logOut();
105+
} catch(e) { /* ignore */ }
106+
done();
107+
});
105108
});
106109

107110
it('ensure that email is uniquely indexed', async done => {
108-
Parse.User.disableUnsafeCurrentUser();
111+
try {
112+
await Parse.User.logOut();
113+
} catch(e) { /* ignore */ }
109114
let numFailed = 0;
110115
let numCreated = 0;
111116
const user1 = new Parse.User();
@@ -140,13 +145,19 @@ describe('miscellaneous', function() {
140145
.then(() => {
141146
fail('one of the users should not have been created');
142147
})
143-
.finally(() => {
144-
Parse.User.enableUnsafeCurrentUser();
148+
.catch(() => {})
149+
.finally(async () => {
150+
try {
151+
await Parse.User.logOut();
152+
} catch(e) { /* ignore */ }
145153
done();
146154
});
147155
});
148156

149-
it('ensure that if people already have duplicate users, they can still sign up new users', done => {
157+
it('ensure that if people already have duplicate users, they can still sign up new users', async done => {
158+
try {
159+
await Parse.User.logOut();
160+
} catch(e) { /* ignore */ }
150161
const config = Config.get('test');
151162
// Remove existing data to clear out unique index
152163
TestUtils.destroyAllDataPermanently()

0 commit comments

Comments
 (0)