This repository was archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
47 lines (37 loc) · 1.31 KB
/
test.js
File metadata and controls
47 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const assert = require('assert');
const browserify = require('browserify');
const bundler = browserify().add('dist/index.cjs').require('jquery');
const jsdom = require('jsdom');
const virtualConsole = new jsdom.VirtualConsole();
const { window } = new jsdom.JSDOM('<!DOCTYPE html><body>', {
virtualConsole,
runScripts: "dangerously"
});
const $ = require('jquery')(window);
describe('owlCarousel plugin', function() {
let localJQueryHasOwlCarousel;
before(function(done) {
virtualConsole.once('log', (message) => {
localJQueryHasOwlCarousel = message;
});
bundler
.bundle((error, bundle) => {
const script = window.document.createElement('script');
let inline = window.document.createTextNode(bundle.toString());
script.appendChild(inline);
inline = window.document.createTextNode(`
const $ = require('jquery');
console.log('owlCarousel' in $.fn);
`);
script.appendChild(inline);
window.document.body.appendChild(script);
done();
});
})
it('global jQuery should not contain owlCarousel plugin', function() {
assert.strictEqual('owlCarousel' in $.fn, false);
});
it('local jQuery should contain owlCarousel plugin', function() {
assert.strictEqual(localJQueryHasOwlCarousel, true);
});
});