I'm getting this error from Mocha:
Uncaught AssertionError: expected 'long-title-abcdefghijklmnopqrs' to equal 'long-title-abcdefghijklmnopqrs'
This doesn't make any sense because those strings appear to be equal. Here's the test code:
it('shortens and joins title to 30 characters and with -', function(done){
article.createMdArticle('long title abcdefghijklmnopqrstubwxyz', 'the bod', function(err, doc){
if(err) throw err;
doc.url_title.should.eql('long-title-abcdefghijklmnopqrs');
done();
})
})
and this mongoose pre('save') hook which creates url_title from title
articleSchema.pre('save', function (next) {
//makes 'test title' into 'test-title'
this.url_title = this.title.split(' ').join('-').substring(0,30);
console.log(this.url_title);
next();
});
All of my other tests that compare any other object data work as expected
Figured it out... in my articleSchema mongoose schema...
var articleSchema = new Schema({
title : { type: String, index: { unique: true, required: true }},
body: { type: String, required: true },
url_title: { sype: String},
});
on the url_title line, it says sype: String instead of type: String. When I corrected this, the error was no more.