forked from inventures/hatchjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomment.test.js
34 lines (29 loc) · 1.02 KB
/
comment.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var should = require('./');
var app, compound, Content, Comment;
var async = require('async');
describe('Comment', function() {
before(function (done) {
app = getApp(done);
compound = app.compound;
Content = compound.models.Content;
Comment = compound.models.Comment;
});
it('should create 5 comments on a content post and check cached comments.length == 3', function(done) {
Content.create({
createdAt: new Date,
title: 'Hello',
text: 'World'
}, function(err, content) {
async.times(5, function (n, done) {
content.postComment(1, 'hello', done);
}, function () {
// reload the content
Content.find(content.id, function (err, content) {
content.comments.items.length.should.equal(Content.CACHEDCOMMENTS);
content.commentsTotal.should.equal(5);
done();
});
});
});
});
});