var app;
var supertest;
// Uncomment if you want to include common exports.options or similar
//var common = require("./common");
function importTest(name, path) {
describe(name, function () {
require(path);
});
};
describe("My Test Suite", function () {
before(function () {
//console.log("running something before each test");
app = require('../server/server');
supertest = require('supertest');
global.api = supertest(app);
});
beforeEach(function () {
//console.log("running something before each test");
});
importTest("User", './User/test');
importTest("CutomerAccount", './CustomerAccount/test');
after(function () {
console.log("after all tests");
});
});describe('/Users test suite', function () {
describe('login/logout for Test Admin user', function () {
var token;
var verificationToken;
var demoUserId;
var redirectLink;
it('should NOT be able to create a user (without access_token)', function(done) {
api.post('/api/Users')
.send({email:"new...@example.com", password: "mypassword"})
.expect(401, done);
});
it('should login as Test Admin user', function(done) {
api.post('/api/Users/login')
.send({email:"test_...@example.com", password: "myadminpassword"})
.expect(200)
.end(function(err, res) {
if (err) return done(err);
token = res.body.id;
done();
});
});
it('should be able to create a Demo user', function(done) {
api.post('/api/Users')
.query({access_token: token})
.send({email:"de...@example.com", password: "mydemopassword"})
.expect(200)
.end(function(err, res){
if (err) return done(err);
verificationToken = res.body.verificationToken;
demoUserId = res.body.id;
redirectLink = 'http://0.0.0.0/verified?user_id='+demoUserId;
done();
});
});
it('should logout from Test Admin user', function(done) {
api.post('/api/Users/logout')
.query({access_token: token})
.expect(204, done);
});
it('should be able to verify the Demo user', function(done) {
api.get('/api/Users/confirm')
.query({uid: demoUserId, redirect: redirectLink, token: verificationToken})
.expect(302, done);
});
});
describe('login/logout for regular User', function (){
...
});
describe('restrictions for non-Admin users', function () {
...
});
});--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/3XrkUA-jI-k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/5ecce0b3-da09-4138-a294-8956eb2dd62d%40googlegroups.com.
/serv
Be sure to use the correct capitalization, but basically my structure is as follows:MyApplication/ <----- root folderMyApplication/server <----- server filesMyApplication/test <------ test folderMyApplication/test/top.js <--------- top test fileMyApplication/test/common.js <--------- common exportsMyApplication/test/User/test.js <--------- tests for User modelMyApplication/test/OtherModel/test.js <--------- tests for OtherModel modelMyApplication/test/YetAnotherModel/test.js <--------- tests for YetAnotherModel modelAnd so on. You can also put everything under MyApplication/test/test1.js, test2.js, etc, but I find it easier to enable/disable tests and to overall understand better what exactly I am testing.Basically all tests should be under MyApplication/test folder.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/4934569e-442e-4a18-930f-e61c908727ee%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/1444c5d2-5745-44f9-8555-5d837dc62da2%40googlegroups.com.