Background:
I have a field of type Markdown. When I try unit testing it, the value initializes to what's seen below -- which passes validation.
{
"html": [undefined]
"md": [undefined]
"toJSON": [Function]
"toObject": [Function]
}
The model is as follows:
var keystone = require('keystone');
var Types = keystone.Field.Types;
/**
* Test Model
* ==========
*/
var Test = new keystone.List('Test');
Test.add({
name: {type: Types.Name, required: true, initial: true, index: true},
otherField: {type: Types.Markdown, initial: true, required: true},
});
/**
* Registration
*/
Test.defaultColumns = 'name, otherField';
Test.register();
module.exports = Test;
and the test:
var expect = require('chai').expect;
var keystone = require('keystone');
describe('Test', function() {
keystone.init({name: 'Test Example'});
keystone.import('../../models');
var Test;
it('should should fail validation when otherField is empty',function(done) {
Test = keystone.list('Test');
var test = new Test.model();
test.name.full = 'Jane Doe';
test.save(function(err) {
expect(err.name).to.equal('ValidationError');
done();
});
});
});
When running as is, the save passes with no error, so it doesn't hit done and times out. Switching the type to flat field types such as Text, Html, Boolean, Color, Date, Datetime, or Key will work as expected(ValidationError). I get the same issue if I switch the type to be another embedded type such as Name or Location.
Questions: