Skip to content

Commit 9f0d66b

Browse files
Added a test
1 parent 571d8b7 commit 9f0d66b

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

routes/api/account.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ module.exports = {
178178
* @apiName inviteAccount
179179
* @apiGroup Account
180180
* @apiVersion 0.0.8
181+
* @apiDescription sends link with token to be used with the account/create route
181182
*
182183
* @apiParam (body) {String} [email] email of the account to be created and where to send the link
183184
* @apiParam (body) {String} [accountType] the type of the account which the user can create, for sponsor this should specify tier as well

tests/account.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,18 @@ describe("POST confirm account", function () {
219219
res.body.message.should.equal(Constants.Error.ACCOUNT_TOKEN_401_MESSAGE);
220220
done();
221221
})
222-
})
222+
});
223+
it("should FAIL to confirm account that has token with email but no account", function(done) {
224+
chai.request(server.app)
225+
.post('/api/auth/confirm/' + fakeToken)
226+
.type("application/json")
227+
.end(function (err, res) {
228+
res.should.have.status(401);
229+
res.body.should.have.property("message");
230+
res.body.message.should.equal(Constants.Error.ACCOUNT_TOKEN_401_MESSAGE);
231+
done();
232+
})
233+
});
223234
})
224235

225236
describe("PATCH update account", function () {

tests/util/accountConfirmation.test.util.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const HackerConfirmation2 = {
2828
"email": Util.Account.NonConfirmedAccount2.email
2929
}
3030

31+
const HackerConfirmation3 = {
32+
"_id": mongoose.Types.ObjectId(),
33+
"email": Util.Account.newAccount1
34+
};
35+
3136
// Using a real ID which is stored but corresponds to another account
3237
const FakeHackerToken = {
3338
"_id": HackerConfirmation._id,
@@ -40,7 +45,8 @@ const FakeToken = Services.AccountConfirmation.generateToken(FakeHackerToken._id
4045

4146
const AccountConfirmationTokens = [
4247
HackerConfirmation,
43-
HackerConfirmation2
48+
HackerConfirmation2,
49+
HackerConfirmation3
4450
];
4551

4652
function storeAll(attributes) {

0 commit comments

Comments
 (0)