test/unit/source/js/events.spec.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 33
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 33
rs 10
wmc 4
mnd 0
bc 4
fnc 4
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B events.spec.js ➔ describe(ꞌeventsꞌ) 0 24 1
1
'use strict';
2
3
var _ = require('lodash');
4
var expect = require('chai').expect;
5
var path = require('path');
6
var sinon = require('sinon');
7
8
var projectRoot = path.resolve(__dirname, '..', '..', '..', '..');
9
10
describe('events', function () {
11
  var runtime;
12
13
  before(function () {
14
    _.set(global, 'chrome.runtime', {
15
      onMessage: {
16
        addListener: sinon.spy()
17
      }
18
    });
19
20
    runtime = global.chrome.runtime;
21
  });
22
23
  describe('initialization', function () {
24
    it('should bind to message events', function () {
25
      var initialCallCount = runtime.onMessage.addListener.callCount;
26
27
      // eslint-disable-next-line
28
      require(path.join(projectRoot, 'source', 'js', 'events'));
29
30
      expect(runtime.onMessage.addListener.callCount).to.be.greaterThan(initialCallCount);
31
    });
32
  });
33
});
34