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
|
|||
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 |
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.