@janiscommerce/model-test
v1.0.0
Published
A package to test Janis Models
Downloads
802
Readme
model-test
A helper package to test Janis Model created with @janiscommerce/model.
:hammer: Usage
You must add a ./tests/model-test.js
file like the following.
'use strict';
const modelTest = require('@janiscommerce/model-test');
modelTest();
Models
The package will look for the models of a service located in the ./{process.env.MS_PATH}/models/
folder.
Validations
The package automatically will validate each model according @janiscommerce/model.
The validations performed by the package are as follows
Table/Collection
The table/collection is validated using the static getter table
. Should return a String value.
Database Key
The databaseKey is validated using the non-static getter databaseKey
. Should return a String value.
Statuses
The statuses are validated using the static getter statuses
. Should return an Object with keys and values as Strings.
Fields
The fields are validated using the static getter fields
. Should return an Object with keys and values as Strings.
The validation is performed with a struct.
'use strict';
const { struct } = require('superstruct');
module.exports = struct.partial({
field: 'string?',
type: 'string?'
});
Indexes
The indexes are validated using the static getter indexes
. Should return an Object with keys and values as Strings.
The validation is performed with a struct.
'use strict';
const { struct } = require('superstruct');
module.exports = struct.partial({
name: 'string',
key: 'object',
unique: 'boolean?',
expireAfterSeconds: 'number?',
partialFilterExpression: 'object?',
sparse: 'boolean?'
});
For more information see @janiscommerce/mongodb-index-creator.
Log Creation
The automatic Log Creation is validated using the static getter shouldCreateLogs
. Should return a Boolean.
For more information see @janiscommerce/log.
Excluding fields from logs
The validation is performed using the static getter excludeFieldsInLog
. Should return a String Array.
For more information see @janiscommerce/log.