O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Test implementation

We will create three tests for our command service: the first will test if the roll_a_dice command works as expected; the second will check the echo command; and the last will check the response of the service when using a command that is not supported.

Create a file called command_test.js and paste in the following code to implement our test suite:

let assert = require('assert'); let mockDataSourceFactory = require('./mock_datasource_factory'); let servicesFactory = require('../src/services'); describe('Command Test',function(){     it('Must support roll_a_dice command',function(done){         let mockDataSource = mockDataSourceFactory();         let services = servicesFactory(mockDataSource);         let me = 'John Doe';  let message = {from:me,action:'roll_a_dice'}; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required