Permalink
Browse files

add user, checkoff, and city model tests

  • Loading branch information...
bvellek committed Apr 27, 2017
1 parent 884dad1 commit d1e92d19a05a0cd8e93c31c114c0c60d4cb8dfc3
Showing with 147 additions and 3 deletions.
  1. +5 −3 package.json
  2. +28 −0 test/test-CheckoffModel.js
  3. +33 −0 test/test-CityModel.js
  4. +28 −0 test/test-UserModel.js
  5. +53 −0 yarn.lock
View
@@ -13,8 +13,9 @@
},
"scripts": {
"start": "node server.js",
"test": "cd client && yarn install && yarn test && cd ../",
"test2": "cd client && yarn install && yarn test && cd ../ && yarn install && mocha test"
"test-server": "mocha test",
"test-client": "cd client && yarn install && yarn test && cd ../",
"test": "cd client && yarn install && yarn test && cd ../ && yarn install && mocha test"
},
"dependencies": {
"bcrypt-nodejs": "^0.0.3",
@@ -34,6 +35,7 @@
"chai-http": "^3.0.0",
"eslint": "^3.19.0",
"eslint-config-equimper": "^1.6.2",
"mocha": "^3.2.0"
"mocha": "^3.2.0",
"sinon": "^2.1.0"
}
}
View
@@ -0,0 +1,28 @@
const expect = require('chai').expect;
const Checkoff = require('../models/checkoff');
describe('Checkoff Model', () => {
it('should be invalid if breweryID, userID, cityID are empty', (done) => {
const checkoffTest = new Checkoff();
checkoffTest.validate((err) => {
expect(err.errors.cityID).to.exist;
expect(err.errors.userID).to.exist;
expect(err.errors.breweryID).to.exist;
done();
});
});
it('should not throw error for userID = string, breweryID = string,cityID = string', (done) => {
const checkoffTest = new Checkoff({
userID: 'TEST123',
breweryID: 'breW1',
cityID: 'adsfl3',
});
checkoffTest.validate((err) => {
expect(err).to.not.exist;
done();
});
});
});
View
@@ -0,0 +1,33 @@
const expect = require('chai').expect;
const City = require('../models/city');
describe('City', () => {
it('should be invalid if cityName, lat, lng, and userID are empty', (done) => {
const cityTest = new City();
cityTest.validate((err) => {
expect(err.errors.cityName).to.exist;
expect(err.errors['cityCoords.lat']).to.exist;
expect(err.errors['cityCoords.lng']).to.exist;
expect(err.errors.userID).to.exist;
done();
});
});
it('should not throw error for cityName = string, lat = number, lng = number, and userId = string', (done) => {
const cityTest = new City({
cityName: 'Seattle, WA',
userID: 'TEST123',
cityCoords: {
lat: 123,
lng: 456,
},
brewTotal: 5,
});
cityTest.validate((err) => {
expect(err).to.not.exist;
done();
});
});
});
View
@@ -0,0 +1,28 @@
const expect = require('chai').expect;
const User = require('../models/user');
describe('User Model', () => {
it('should be invalid if email, firstName, lastName are empty', (done) => {
const userTest = new User();
userTest.validate((err) => {
expect(err.errors.email).to.exist;
expect(err.errors.firstName).to.exist;
expect(err.errors.lastName).to.exist;
done();
});
});
it('should not throw error for email = string, firstName = string, lastName = string', (done) => {
const userTest = new User({
email: 'test@test.com',
firstName: 'John',
lastName: 'Doe',
});
userTest.validate((err) => {
expect(err).to.not.exist;
done();
});
});
});
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit d1e92d1

Please sign in to comment.