field.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. var deprecated = require('../');
  2. var should = require('should');
  3. require('mocha');
  4. describe('field()', function() {
  5. it('should return a wrapped function that logs once on get', function(done) {
  6. var message = 'testing';
  7. var scope = {
  8. a: 1
  9. };
  10. var obj = {};
  11. var logged = false;
  12. var log = function(msg){
  13. msg.should.equal(message);
  14. logged.should.equal(false);
  15. logged = true;
  16. };
  17. deprecated.field(message, log, obj, 'a', 123);
  18. obj.a.should.equal(123);
  19. obj.a = 1234;
  20. obj.a.should.equal(1234);
  21. logged.should.equal(true);
  22. done();
  23. });
  24. it('should return a wrapped function that logs once on set', function(done) {
  25. var message = 'testing';
  26. var scope = {
  27. a: 1
  28. };
  29. var obj = {};
  30. var logged = false;
  31. var log = function(msg){
  32. msg.should.equal(message);
  33. logged.should.equal(false);
  34. logged = true;
  35. };
  36. deprecated.field(message, log, obj, 'a', 123);
  37. obj.a = 1234;
  38. logged.should.equal(true);
  39. done();
  40. });
  41. });