1.2.0 • Published 8 years ago

mongoose-test v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

mongooose-test

A few test helper to make testing mongoose easier.

Build Status

##How to use

##Insert documents with some value.

    var RequireStringDummy = mongoose.model('DummyStringRequired', new mongoose.Schema({
        a: Number,
        b: {type: String, required: true},
        c: {type: String, required: true, enum: ['hongbosb', 'shijiesb']}
    }))
    var mongooseTest = require('mongoose-test')
        return mongooseTest.init(RequireStringDummy, [{a: 1}, {a: 2}]);
    }

##Insert documents with all random values.

    var RequireStringDummy = mongoose.model('DummyStringRequired', new mongoose.Schema({
        a: Number,
        b: {type: String, required: true},
        c: {type: String, required: true, enum: ['hongbosb', 'shijiesb']}
    }))
    var mongooseTest = require('mongoose-test')
        return mongooseTest.init(RequireStringDummy, new Array(3));
    }

When the inserted document contains some required fields that doesn't have value, mongooseTest will automatically generate some dummy data according its type. In the above example, we don't need to specify b and c these two required fields. But after call insertData we will still find some strings in these fields. So with this strategy, you only need to concentrate on the fields you care, let let mongoose-test do the rest work.

##Install

npm install --save mongoose-test
1.2.0

8 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago