3 var persistence
= require('gitter-web-persistence');
4 var assert
= require('assert');
5 var fixtureLoader
= require('gitter-web-test-utils/lib/test-fixtures');
6 var getModelVersion
= require('../lib/get-model-version');
8 describe('get-model-version', function() {
9 describe('using real mongoose objects #slow', function() {
10 var fixture
= fixtureLoader
.setup({
14 describe('with initial value', function() {
15 it('should read the _tv value ', function() {
16 return persistence
.User
.findOne({ _id
: fixture
.user1
._id
}).then(function(user
) {
17 var v
= getModelVersion(user
);
18 assert
.strictEqual(v
, 1);
22 it('should read the _tv value on lean objects', function() {
23 return persistence
.User
.findOne(
24 { _id
: fixture
.user1
._id
},
27 ).then(function(user
) {
28 var v
= getModelVersion(user
);
29 assert
.strictEqual(v
, 1);
34 describe('after increment', function() {
36 return fixture
.user1
.save();
39 it('should read the _tv value ', function() {
40 return persistence
.User
.findOne({ _id
: fixture
.user1
._id
}).then(function(user
) {
41 var v
= getModelVersion(user
);
42 assert
.strictEqual(v
, 2);
46 it('should read the _tv value on lean objects', function() {
47 return persistence
.User
.findOne(
48 { _id
: fixture
.user1
._id
},
51 ).then(function(user
) {
52 var v
= getModelVersion(user
);
53 assert
.strictEqual(v
, 2);