const generateUser = () => { const createdAt = faker.date.past(2); const name = faker.name.findName(); return { id: uuid(), name, description: casual.short_description(), website: faker.internet.url(), username: faker.internet.userName(name), profilePhoto: faker.internet.avatar(), coverPhoto: faker.image.image(), email: faker.internet.email(name), providerId: uuid(), createdAt, // Make sure lastSeen is > createdAt lastSeen: faker.date.between(createdAt, new Date()), }; }
const defineFakeUsers = () => ({ uuid: faker.random.uuid(), username: faker.internet.userName(), avatar: faker.internet.avatar(), lastOnline: faker.date.recent(), })
router.post("/", function (req, res) { var user = { firstName: faker.name.firstName(), lastName: faker.name.lastName(), username: faker.internet.userName(), email: faker.internet.email() }; data.push(user); res.status(200).send(user); });
function getLargeData() { var result = []; for(var i=0; i<5000; i++) { result.push({ name: faker.name.findName(), email: faker.internet.email(), country: faker.address.country(), city: faker.address.city(), company: faker.company.companyName(), userName: faker.internet.userName(), phoneNumber: faker.phone.phoneNumber() }); } return result; }
const seedUsers = async () => { console.log('Seeding users...'); let users = []; // generate 10 user profiles for (var i = 0; i < 10; i++) { let user = { username: faker.internet.userName(), password: await bcrypt.hash('password', 10), email: faker.internet.email() }; user.avatar = gravatar(user.email); users.push(user); } return users; }
it('should return all current SMS sent logs', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() }); nock(transport.baseUrl) .get(transport.logsUrl) .reply(function ( /*uri, requestBody*/ ) { //assert headers expect(this.req.headers.accept).to.equal('application/json'); expect(this.req.headers.host).to.equal('api.infobip.com'); expect(this.req.headers.authorization).to.not.be.null; return [200, logs]; }); //request all account logs transport.getSentSMSLogs(function (error, logs) { expect(error).to.be.null; expect(logs).to.exist; expect(logs.results).to.exist; expect(logs.results.length).to.be.equal(3); done(); }); });
it('should send a single sms to a single destination', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() });
it('should return unauthorized error when invalid credentials provided', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() });
it('should return current account balance', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() });
it('should return all current SMS delivery report', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() }); nock(transport.baseUrl) .get(transport.deliveryReportUrl) .reply(function ( /*uri, requestBody*/ ) { //assert headers expect(this.req.headers.accept).to.equal('application/json'); expect(this.req.headers.host).to.equal('api.infobip.com'); expect(this.req.headers.authorization).to.not.be.null; return [200, deliveries]; }); //request account deliveries transport.getDeliveryReports(function (error, deliveryReport) { expect(error).to.be.null; expect(deliveryReport).to.exist; expect(deliveryReport.results).to.exist; expect(deliveryReport.results.length).to.be.equal(3); done(); }); });
it('should return all received SMS(s) so far', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() }); nock(transport.baseUrl) .get(transport.receivedUrl) .reply(function ( /*uri, requestBody*/ ) { //assert headers expect(this.req.headers.accept).to.equal('application/json'); expect(this.req.headers.host).to.equal('api.infobip.com'); expect(this.req.headers.authorization).to.not.be.null; return [200, receivedSMS]; }); //request account received SMS(s) transport.getReceivedSMS(function (error, receivedSMS) { expect(error).to.be.null; expect(receivedSMS).to.exist; expect(receivedSMS.results).to.exist; expect(receivedSMS.results.length).to.be.equal(2); done(); }); });
it('should return all received SMS(s) log', function (done) { var transport = new Transport({ username: faker.internet.userName(), password: faker.internet.password() }); nock(transport.baseUrl) .get(transport.receivedLogUrl) .reply(function ( /*uri, requestBody*/ ) { //assert headers expect(this.req.headers.accept).to.equal('application/json'); expect(this.req.headers.host).to.equal('api.infobip.com'); expect(this.req.headers.authorization).to.not.be.null; return [200, receivedSMSLog]; }); //request account received SMS(s) log transport.getReceivedSMSLogs(function (error, receivedSMSLog) { expect(error).to.be.null; expect(receivedSMSLog).to.exist; expect(receivedSMSLog.results).to.exist; expect(receivedSMSLog.results.length).to.be.equal(4); done(); }); });
const defineFakeUsers = () => ({ uuid: faker.random.uuid(), username: faker.internet.userName(), avatar: faker.internet.avatar(), lastOnline: faker.date.recent(), })
const defineFakeUsers = () => ({ uuid: faker.random.uuid(), username: faker.internet.userName(), avatar: faker.internet.avatar(), lastOnline: faker.date.recent(), })