-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from two-factor/editnpm
updated package.json
- Loading branch information
Showing
4 changed files
with
82 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
const verify = require('../functions/verify') | ||
//On client check verify | ||
const verify = require("../../functions/verify"); | ||
//On client check verify | ||
|
||
describe('#verify', () => { | ||
class FakeClient { | ||
describe("#verify", () => { | ||
class FakeClient { | ||
constructor(isError) { | ||
this.client = { | ||
verify: { | ||
services: () => ({ | ||
verificationChecks: { | ||
create: ({to, code}) => { | ||
return new Promise((resolve,reject) => { | ||
if(!isError) resolve({status: 'approved'}) | ||
else reject({status: false }) | ||
}) | ||
} | ||
} | ||
}) | ||
verify: { | ||
services: () => ({ | ||
verificationChecks: { | ||
create: ({ to, code }) => { | ||
return new Promise((resolve, reject) => { | ||
if (!isError) resolve({ status: "approved" }); | ||
else reject({ status: false }); | ||
}); | ||
} | ||
} | ||
}) | ||
} | ||
}; | ||
this.verify = verify; | ||
this.users = { Zep: { sid: "Zep3246", phone: "3479087000" } }; | ||
} | ||
this.verify = verify | ||
this.users = {'Zep': {'sid':'Zep3246', 'phone':'3479087000'}} | ||
} | ||
} | ||
|
||
it('throws an error if this.users is empty', () => { | ||
const fakeClient = new FakeClient(false) | ||
// FakeClient.users = {} | ||
return expect((fakeClient.verify('ian'))).rejects.toBeInstanceOf(Error) | ||
}) | ||
it("throws an error if this.users is empty", () => { | ||
const fakeClient = new FakeClient(false); | ||
// FakeClient.users = {} | ||
return expect(fakeClient.verify("ian")).rejects.toBeInstanceOf(Error); | ||
}); | ||
|
||
it('throws an error if sid of the user not found', () => { | ||
const fakeClient = new FakeClient(false) | ||
fakeClient.users['Zep'].sid = null | ||
// FakeClient.users = {} | ||
return expect((fakeClient.verify('Zep'))).rejects.toBeInstanceOf(Error) | ||
}) | ||
it("throws an error if sid of the user not found", () => { | ||
const fakeClient = new FakeClient(false); | ||
fakeClient.users["Zep"].sid = null; | ||
// FakeClient.users = {} | ||
return expect(fakeClient.verify("Zep")).rejects.toBeInstanceOf(Error); | ||
}); | ||
|
||
it('throws an error if phone of the user not found', () => { | ||
const fakeClient = new FakeClient(false) | ||
fakeClient.users['Zep'].phone = null | ||
// FakeClient.users = {} | ||
return expect((fakeClient.verify('Zep'))).rejects.toBeInstanceOf(Error) | ||
}) | ||
it("throws an error if phone of the user not found", () => { | ||
const fakeClient = new FakeClient(false); | ||
fakeClient.users["Zep"].phone = null; | ||
// FakeClient.users = {} | ||
return expect(fakeClient.verify("Zep")).rejects.toBeInstanceOf(Error); | ||
}); | ||
|
||
it('status approved if the code matches', () => { | ||
const fakeClient = new FakeClient(false) | ||
return expect((fakeClient.verify('Zep'))).resolves.toBeTruthy() | ||
}) | ||
}) | ||
it("status approved if the code matches", () => { | ||
const fakeClient = new FakeClient(false); | ||
|
||
return expect(fakeClient.verify("Zep")).resolves.toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters