| Total Complexity | 5 |
| Complexity/F | 1 |
| Lines of Code | 25 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | 'use strict' |
||
| 2 | var mongoose = require('mongoose') |
||
| 3 | var Customer = mongoose.model('Customer') |
||
| 4 | var chai = require('chai') |
||
| 5 | var expect = chai.expect |
||
| 6 | |||
| 7 | describe('Unit Test Customer Model', function () { |
||
| 8 | it('should be invalid if name is empty', function (done) { |
||
| 9 | var customer = new Customer() |
||
| 10 | |||
| 11 | customer.validate(function (err) { |
||
| 12 | expect(err.errors.name).to.exist |
||
|
|
|||
| 13 | done() |
||
| 14 | }) |
||
| 15 | }) |
||
| 16 | |||
| 17 | it('should be valid if it has a name', function (done) { |
||
| 18 | var customer = new Customer({ name: 'Neil Grogan' }) |
||
| 19 | |||
| 20 | customer.validate(function (err) { |
||
| 21 | expect(err).to.not.exist |
||
| 22 | done() |
||
| 23 | }) |
||
| 24 | }) |
||
| 25 | }) |
||
| 26 |