Skip to content

Commit

Permalink
Merge pull request #39 from two-factor/package
Browse files Browse the repository at this point in the history
Updated package.json and semver
  • Loading branch information
Dnaganog committed Jul 9, 2019
2 parents 3a4ece2 + 0ce3bf0 commit b672cc0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 54 deletions.
96 changes: 45 additions & 51 deletions __tests__/functions/databases/mongoose/create.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,52 @@
const mongoose = require('mongoose');
const mongooseCreate = require ('../../../../functions/databases/mongoose/create');
const mongoose = require("mongoose");
const mongooseCreate = require("../../../../functions/databases/mongoose/create");

describe('tests the create function', () => {
class FakeClient {
constructor(
AccSID,
AuthToken
) {
this.AccSID = AccSID;
this.AuthToken = AuthToken;
this.client = {
verify: {
services: {
create: () => {
const isError = this.isError;
return new Promise((resolve, reject) => {
if (isError) {
reject(new Error("fake error message"));
}
resolve({
sid: "fakeSid"
});
});
describe("tests the create function", () => {
class FakeClient {
constructor(AccSID, AuthToken) {
this.AccSID = AccSID;
this.AuthToken = AuthToken;
this.client = {
verify: {
services: {
create: () => {
const isError = this.isError;
return new Promise((resolve, reject) => {
if (isError) {
reject(new Error("fake error message"));
}
}
resolve({
sid: "fakeSid"
});
});
}
};
this.TwoAuthUser = {
create: ({
userID,
sid,
phone
}) => {
return new Promise((resolve, reject) => {
resolve(5)
})
}
};
this.create = mongooseCreate;
}
}
};
this.TwoAuthUser = {
create: ({ userID, sid, phone }) => {
return new Promise((resolve, reject) => {
resolve(5);
});
}
}
};
this.create = mongooseCreate;
}
}

it('generates a user with the right sid', async () => {
const newClient = new FakeClient();
// create a user using client.create()
let result = await newClient.create('ian', '+17604307620')
expect(result).toBe(5)
// query database for that user
});
it("generates a user with the right sid", async () => {
const newClient = new FakeClient();
// create a user using client.create()
let result = await newClient.create("ian", "+17604307620");
expect(result).toBe(5);
// query database for that user
});

it('passes error message on rejection', () => {
const newClient = new FakeClient();
let users = newClient.users;
newClient.create('ian', '+17604307620').catch(err => { expect(err instanceof Error).toBeTruthy();
});
it("passes error message on rejection", () => {
const newClient = new FakeClient();
let users = newClient.users;
newClient.create("ian", "+17604307620").catch(err => {
expect(err instanceof Error).toBeTruthy();
});
});
});
});
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "two-auth",
"version": "1.0.2",
"description": "This is the two factor twilio library.",
"version": "2.0.0",
"description": "Implement two-factor SMS authentication with the Twilio API in three lines of code.",
"main": "index.js",
"scripts": {
"test": "jest --verbose"
Expand All @@ -12,6 +12,8 @@
},
"keywords": [
"2fa",
"sms",
"two factor",
"two-factor",
"two",
"two-factor-authentication",
Expand All @@ -37,4 +39,4 @@
"dotenv": "^8.0.0",
"jest": "^24.8.0"
}
}
}

0 comments on commit b672cc0

Please sign in to comment.