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 only one test for our blockUser() service: our test will check that we do not receive messages from a given user after calling the service.

Create a file called block_user_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('Block user Test',function(){     it('Must not receive message from blocked user',function(done){         let mockDataSource = mockDataSourceFactory();         let services = servicesFactory(mockDataSource);         let receivedMessage = false;         let me = 'John Doe';         let blocked = 'Jim';         let content = 'foobar';  let message = {to:me,content:content}; ...

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