Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:two-factor/two-factor into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
iangeckeler committed Jul 9, 2019
2 parents beb3264 + 6eca9a4 commit cc09c76
Showing 1 changed file with 62 additions and 3 deletions.
65 changes: 62 additions & 3 deletions __tests__/functions/databases/postgresql/verify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
describe('', () => {

}
const verify = require("../../../../functions/databases/postgres/verify");

describe("test for postgres", () => {
class FakeClient {
constructor() {
this.pgConnect = function() {
return new Promise((resolve, reject) => {
resolve({
database: {
query: function(query, values, callback) {
return new Promise((resolve, reject) => {
resolve({
rows: [
{
sid: "fakesid",
phone: "1234"
}
]
});
});
}
},
done: function() {
return null;
}
});
});
};
this.client = {
verify: {
services: function(sid) {
return {
verificationChecks: {
create: function({ code }) {
return new Promise((resolve, reject) => {
if (code === "123456") resolve({ status: "approved" });
else resolve({ status: "rejected" });
});
}
}
};
}
}
};
this.verify = verify;
}
}

it("is false if the verification is wrong", () => {
const client = new FakeClient();
client.verify("zep", "123400").then(result => {
expect(result).toBe(false);
});
});

it("return true from the promise ", () => {
const client = new FakeClient();
client.verify("zep", "123456").then(result => {
expect(result).toBe(true);
});
});
});

0 comments on commit cc09c76

Please sign in to comment.