Passed
Pull Request — master (#17)
by
unknown
57s
created

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

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 31
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 31
rs 10
c 2
b 0
f 0
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 ➔ ??? 0 24 1
1
const _ = require('lodash');
2
const expect = require('chai').expect;
3
const path = require('path');
4
const sinon = require('sinon');
5
6
const projectRoot = path.resolve(__dirname, '..', '..', '..', '..');
7
8
describe('events', () => {
9
  let runtime;
10
11
  before(() => {
12
    _.set(global, 'chrome.runtime', {
13
      onMessage: {
14
        addListener: sinon.spy(),
15
      },
16
    });
17
18
    runtime = global.chrome.runtime;
19
  });
20
21
  describe('initialization', () => {
22
    it('should bind to message events', () => {
23
      const initialCallCount = runtime.onMessage.addListener.callCount;
24
25
      // eslint-disable-next-line
26
      require(path.join(projectRoot, 'source', 'js', 'events'));
27
28
      expect(runtime.onMessage.addListener.callCount).to.be.greaterThan(initialCallCount);
29
    });
30
  });
31
});
32