I
I
IDDH2018-01-13 00:30:05
JavaScript
IDDH, 2018-01-13 00:30:05

Unit testing. Why is an object created with stub's, and not a module connected and stub's redefined in it?

Why are unit tests used to create an object and work with it in this way:

describe('test', function() {

   var node = {
      log: sinon.stub(),
      services: {
        block: {
          getBlock: sinon.stub().callsArgWith(1, 1)
        }
      }
    };

   it('block data should be correct', function(done) {
       var controller = new BlockController({node: node});
        ...
   });

});

and the module is not connected and it is already being redefined:
var Node = require('../node')

describe('test', function() {

   var node = new Node();
   sinon.stub(node, "log");
   sinon.stub(node.services.block, "getBlock").callsArgWith(1, 1);

   it('block data should be correct', function(done) {
      var controller = new BlockController({node: node});
      ...
   });

});

Спасибо!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question