previous.test.js
1.07 KB
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
35
36
37
38
39
40
41
42
'use strict';
/* jshint -W030 */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + '/../../../lib/data-types')
, current = Support.sequelize;
describe(Support.getTestDialectTeaser('Instance'), function () {
describe('previous', function () {
it('should return correct previous value', function () {
var Model = current.define('Model', {
text: {
type: DataTypes.STRING,
get: function (name) {
return this.getDataValue(name);
},
set: function (value, name) {
this.setDataValue(name, value);
}
}
})
, instance
, shouldBeEmpty
, shouldBeA;
instance = Model.build({ text: 'a' }, {
isNewRecord: false
});
shouldBeEmpty = instance.previous('text');
instance.set('text', 'b');
shouldBeA = instance.previous('text');
expect(shouldBeEmpty).to.be.not.ok;
expect(shouldBeA).to.be.equal('a');
});
});
});