These are chat archives for waterlock/waterlock

3rd
Mar 2015
Steven
@rh0dium
Mar 03 2015 21:13
Hey @wayne-o - I'm in the same boat
Hi Guys, I'm struggling a bit with what appears to be a simple problem in testing.
When I use this code I'm getting a TypeError: Cannot read property 'models' of undefined
var User = require("../../../api/models/User.js");
var assert = require('assert');

describe('The User Model', function () {
  describe('before the user is created', function () {
    it('should hash the password', function (done) {
      User.beforeCreate({
          password: 'password'
      }, function (err, user) {
          assert.notEqual(user.password, 'password');
          done();
      });
      //assert.equal("xx", "xx");
      //done();
    });
    it("should be able to create", function (done) {
      User.create({username: "hee", email: "a@b.c", firstName: 'joe', lastName: 'bar', password:"xx"}, function (err, user) {
        assert.notEqual(user, undefined);
        assert.equal(user.username, "hee");
        assert.equal(user.email, "a@b.c");
        assert.equal(user.password, "xx");
        done();
      });
    });


  });
});