node.js - Mocha test with data layer? -
i have question data layer in mocha/should test.
i allready have test.js contains mocha/should test.
the following im supposed this: write tests in mocha/should + sufficient mock-framework (nock job) should verify data layer call correct urls in rest api. tests should not invoke underlying rest api.
i have simple rest api crud. im not sure put in data layer?
//setup tests var var testuserequals = { url: "http://localhost:3000/api/users/:email", method: 'get' }; var testuseremail = { url: "http://localhost:3000/api/users/ultricies.adipiscing@utaliquam.ca", method: 'get', json: true }; //and test email: describe('get specific user email', function(){ it('should return specific user', function(done){ //facade request(testuseremail, function(err, res, body){ if(err){ throw err; } body.email.should.equal("ultricies.adipiscing@utaliquam.ca"); done(); }) }) })
in users.js have emails , password:
module.exports = [ { "email": "ultricies.adipiscing@utaliquam.ca", "password": "0b25a444-d4bc-8819-3632-d38626487588" }]
and data layer, call control.js
var user = require('./users'); function getuser(email, callback){ user.finduser(function(err, user){ if(err) return callback(err); console.log(user); }) };
im little lost on datalayer should contain, , couldn´t find info anywhere.
Comments
Post a Comment