test/jquery.nouislider-range-input.spec.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 49
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 0
wmc 6
eloc 30
nc 1
mnd 0
bc 6
fnc 6
dl 0
loc 49
bpm 1
cpm 1
noi 1
c 2
b 0
f 0
rs 10

3 Functions

Rating   Name   Duplication   Size   Complexity  
A jquery.nouislider-range-input.spec.js ➔ resetBody 0 3 1
A jquery.nouislider-range-input.spec.js ➔ setBody 0 3 1
A jquery.nouislider-range-input.spec.js ➔ ??? 0 30 1
1
/* eslint-disable no-new */
2
3
import chai, {expect} from 'chai';
4
import chaijQ from 'chai-jq';
5
// import sinon from 'sinon';
6
import sinonChai from 'sinon-chai';
7
import fs from 'fs';
8
9
chai.use(chaijQ);
10
chai.use(sinonChai);
11
12
const template = fs.readFileSync('test/fixtures/template.html', 'utf-8');
13
14
function setBody(html) {
15
    document.body.innerHTML = html;
16
}
17
18
function resetBody() {
19
    document.body.innerHTML = '';
20
}
21
22
describe('jquery.nouislider-range-input', () => {
23
    let $;
24
25
    beforeEach(() => {
26
        jest.resetModules();
0 ignored issues
show
Bug introduced by
The variable jest seems to be never declared. If this is a global, consider adding a /** global: jest */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
27
        $ = require('jquery');
28
        require('../src');
29
    });
30
31
    afterEach(resetBody);
32
33
    test('register as a function on the jQuery prototype', () => {
34
        expect($.fn.enableNoUISlider).to.be.a('function');
35
    });
36
37
    test('enable nouislider on a range input', () => {
38
        setBody(template);
39
40
        $('.my-custom-class-enabling-nouislider').enableNoUISlider();
41
42
        expect($('.my-custom-class-enabling-nouislider'))
43
            .to.have.$class('js-nouislider-initialized');
44
45
        expect(
46
            $('.my-custom-class-enabling-nouislider')
47
                .siblings('div.nouislider-range-wrapper')
48
                .children('div').eq(0)
49
        ).to.have.$class('noUi-target');
50
    });
51
});
52