-
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.
- Loading branch information
1 parent
510f720
commit ca6e860
Showing
2 changed files
with
62 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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" | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
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('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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const mongoose = require("mongoose"); | ||
const mongooseSend = require("../../../../functions/databases/mongoose/send"); | ||
|
||
|