-
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 #39 from two-factor/package
Updated package.json and semver
- Loading branch information
Showing
2 changed files
with
50 additions
and
54 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
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(); | ||
}); | ||
}); | ||
}); | ||
}); |
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