Opal-Estate-Pro/node_modules/deprecated/test/field.js
2019-09-13 11:27:52 +07:00

44 lines
1.0 KiB
JavaScript
Executable File

var deprecated = require('../');
var should = require('should');
require('mocha');
describe('field()', function() {
it('should return a wrapped function that logs once on get', function(done) {
var message = 'testing';
var scope = {
a: 1
};
var obj = {};
var logged = false;
var log = function(msg){
msg.should.equal(message);
logged.should.equal(false);
logged = true;
};
deprecated.field(message, log, obj, 'a', 123);
obj.a.should.equal(123);
obj.a = 1234;
obj.a.should.equal(1234);
logged.should.equal(true);
done();
});
it('should return a wrapped function that logs once on set', function(done) {
var message = 'testing';
var scope = {
a: 1
};
var obj = {};
var logged = false;
var log = function(msg){
msg.should.equal(message);
logged.should.equal(false);
logged = true;
};
deprecated.field(message, log, obj, 'a', 123);
obj.a = 1234;
logged.should.equal(true);
done();
});
});