Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- const Code = require('code')
- const Lab = require('lab')
- const lab = exports.lab = Lab.script()
- var mongoose = require('mongoose');
- var mockgoose = require('mockgoose');
- mockgoose(mongoose);
- const suite = lab.suite
- const it = lab.test
- const before = lab.before
- const describe = lab.experiment
- const after = lab.after
- const expect = Code.expect
- const beforeEach = lab.beforeEach
- //const proxyquire = require('proxyquire')
- const sinon = require('sinon')
- const partitionData = {
- //cname: 'TESTER',
- description: 'asdf',
- status: true,
- fields: [
- {
- name: 'Hostname',
- type: 'string',
- description: 'Server hostname (FQDN)',
- primary: true,
- visible: true,
- required: true,
- unique: true,
- placeholder: 'server.domain.tld'
- },
- {
- name: 'Description',
- type: 'text',
- description: 'Description of server',
- visible: true,
- required: false,
- unique: false,
- placeholder: 'Server description'
- },
- {
- name: 'Monitoring',
- type: 'boolean',
- description: 'Monitoring status of server',
- visible: true,
- default: true
- }
- ]
- }
- before(function(done) {
- mongoose.connect('mongodb://example.com/TestingDB', function(err) {
- done(err)
- })
- })
- describe('Partition', function () {
- const Models = require('../../../dist/models')(mongoose)
- it("creates a new partition", function(done) {
- let spy = sinon.spy()
- Models.Partition.createPartition( partitionData, (err, data) => {
- if( err ){
- console.log('# ERROR:', err)
- return false
- }
- console.log('# DATA:', data)
- } )
- let Partition = Models.Partition.createPartition( partitionData, spy )
- expect(spy.returned(sinon.match.same({name: 'TESTER'}))).to.equal( true )
- done()
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement