Nessuna descrizione

method.js 803B

1234567891011121314151617181920212223242526272829303132
  1. var deprecated = require('../');
  2. var should = require('should');
  3. require('mocha');
  4. describe('method()', function() {
  5. it('should return a wrapped function that logs once', function(done) {
  6. var message = 'testing';
  7. var scope = {
  8. a: 1
  9. };
  10. var logged = false;
  11. var log = function(msg){
  12. msg.should.equal(message);
  13. logged.should.equal(false);
  14. logged = true;
  15. };
  16. var fn = deprecated.method(message, log, function(one, two){
  17. this.should.equal(scope);
  18. one.should.equal(1);
  19. two.should.equal(2);
  20. return one+two;
  21. });
  22. fn.bind(scope)(1,2).should.equal(3);
  23. fn.bind(scope)(1,2).should.equal(3);
  24. fn.bind(scope)(1,2).should.equal(3);
  25. fn.bind(scope)(1,2).should.equal(3);
  26. logged.should.equal(true);
  27. done();
  28. });
  29. });