dropdownParent-tests.js
2.1 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module('Dropdown - attachBody - dropdownParent option');
test('can be a selector string', function (assert) {
assert.expect(1);
var $ = require('jquery');
var $select = $('<select></select>');
var $parent = $('<div id="parent"></div>');
$('#qunit-fixture').append($parent);
var Utils = require('select2/utils');
var Options = require('select2/options');
var Dropdown = require('select2/dropdown');
var AttachBody = require('select2/dropdown/attachBody');
var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
var dropdown = new DropdownAdapter($select, new Options({
dropdownParent: '#parent'
}));
assert.equal(
dropdown.$dropdownParent[0],
$parent[0],
'Should be parsed using the selector as a jQuery object'
);
});
test('can be a jQuery object', function (assert) {
assert.expect(1);
var $ = require('jquery');
var $select = $('<select></select>');
var $parent = $('<div id="parent"></div>');
$('#qunit-fixture').append($parent);
var Utils = require('select2/utils');
var Options = require('select2/options');
var Dropdown = require('select2/dropdown');
var AttachBody = require('select2/dropdown/attachBody');
var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
var dropdown = new DropdownAdapter($select, new Options({
dropdownParent: $parent
}));
assert.equal(
dropdown.$dropdownParent[0],
$parent[0],
'Should just take the passed in jQuery object'
);
});
test('defaults to the document body', function (assert) {
assert.expect(1);
var $ = require('jquery');
var $select = $('<select></select>');
var Utils = require('select2/utils');
var Options = require('select2/options');
var Dropdown = require('select2/dropdown');
var AttachBody = require('select2/dropdown/attachBody');
var DropdownAdapter = Utils.Decorate(Dropdown, AttachBody);
var dropdown = new DropdownAdapter($select, new Options({}));
assert.equal(
dropdown.$dropdownParent[0],
document.body,
'Should default to wrapping document.body'
);
});