|
1 |
| -describe "Basic setup", -> |
2 |
| - it "should add chosen to jQuery object", -> |
| 1 | +describe 'Basic setup', -> |
| 2 | + it 'should add chosen to jQuery object', -> |
3 | 3 | expect(jQuery.fn.chosen).toBeDefined()
|
4 | 4 |
|
5 |
| - it "should create very basic chosen", -> |
6 |
| - tmpl = " |
7 |
| - <select data-placeholder='Choose a Country...'> |
8 |
| - <option value=''></option> |
9 |
| - <option value='United States'>United States</option> |
10 |
| - <option value='United Kingdom'>United Kingdom</option> |
11 |
| - <option value='Afghanistan'>Afghanistan</option> |
| 5 | + it 'should create very basic chosen', -> |
| 6 | + tmpl = ''' |
| 7 | + <select data-placeholder="Choose a Country..."> |
| 8 | + <option value=""></option> |
| 9 | + <option value="United States">United States</option> |
| 10 | + <option value="United Kingdom">United Kingdom</option> |
| 11 | + <option value="Afghanistan">Afghanistan</option> |
12 | 12 | </select>
|
13 |
| - " |
14 |
| - div = $("<div>").html(tmpl) |
15 |
| - select = div.find("select") |
| 13 | + ''' |
| 14 | + div = $('<div>').html(tmpl) |
| 15 | + select = div.find('select') |
16 | 16 | expect(select.size()).toBe(1)
|
17 | 17 | select.chosen()
|
18 | 18 | # very simple check that the necessary elements have been created
|
19 |
| - ["container", "container-single", "single", "default"].forEach (clazz)-> |
| 19 | + ['container', 'container-single', 'single', 'default'].forEach (clazz)-> |
20 | 20 | el = div.find(".chosen-#{clazz}")
|
21 | 21 | expect(el.size()).toBe(1)
|
22 | 22 |
|
23 | 23 | # test a few interactions
|
24 |
| - expect(select.val()).toBe "" |
| 24 | + expect(select.val()).toBe '' |
25 | 25 |
|
26 |
| - container = div.find(".chosen-container") |
27 |
| - container.trigger("mousedown") # open the drop |
28 |
| - expect(container.hasClass("chosen-container-active")).toBe true |
| 26 | + container = div.find('.chosen-container') |
| 27 | + container.trigger('mousedown') # open the drop |
| 28 | + expect(container.hasClass('chosen-container-active')).toBe true |
29 | 29 | #select an item
|
30 |
| - container.find(".active-result").last().trigger("mouseup") |
| 30 | + container.find('.active-result').last().trigger('mouseup') |
31 | 31 |
|
32 |
| - expect(select.val()).toBe "Afghanistan" |
| 32 | + expect(select.val()).toBe 'Afghanistan' |
33 | 33 |
|
34 |
| - describe "data-placeholder", -> |
| 34 | + describe 'data-placeholder', -> |
35 | 35 |
|
36 |
| - it "should render", -> |
37 |
| - tmpl = " |
38 |
| - <select data-placeholder='Choose a Country...'> |
39 |
| - <option value=''></option> |
40 |
| - <option value='United States'>United States</option> |
41 |
| - <option value='United Kingdom'>United Kingdom</option> |
42 |
| - <option value='Afghanistan'>Afghanistan</option> |
| 36 | + it 'should render', -> |
| 37 | + tmpl = ''' |
| 38 | + <select data-placeholder="Choose a Country..."> |
| 39 | + <option value=""></option> |
| 40 | + <option value="United States">United States</option> |
| 41 | + <option value="United Kingdom">United Kingdom</option> |
| 42 | + <option value="Afghanistan">Afghanistan</option> |
43 | 43 | </select>
|
44 |
| - " |
45 |
| - div = $("<div>").html(tmpl) |
46 |
| - select = div.find("select") |
| 44 | + ''' |
| 45 | + div = $('<div>').html(tmpl) |
| 46 | + select = div.find('select') |
47 | 47 | expect(select.size()).toBe(1)
|
48 | 48 | select.chosen()
|
49 |
| - placeholder = div.find(".chosen-single > span") |
50 |
| - expect(placeholder.text()).toBe("Choose a Country...") |
| 49 | + placeholder = div.find('.chosen-single > span') |
| 50 | + expect(placeholder.text()).toBe('Choose a Country...') |
51 | 51 |
|
52 |
| - it "should render with special characters", -> |
53 |
| - tmpl = " |
54 |
| - <select data-placeholder='<None>'> |
55 |
| - <option value=''></option> |
56 |
| - <option value='United States'>United States</option> |
57 |
| - <option value='United Kingdom'>United Kingdom</option> |
58 |
| - <option value='Afghanistan'>Afghanistan</option> |
| 52 | + it 'should render with special characters', -> |
| 53 | + tmpl = ''' |
| 54 | + <select data-placeholder="<None>"> |
| 55 | + <option value=""></option> |
| 56 | + <option value="United States">United States</option> |
| 57 | + <option value="United Kingdom">United Kingdom</option> |
| 58 | + <option value="Afghanistan">Afghanistan</option> |
59 | 59 | </select>
|
60 |
| - " |
61 |
| - div = $("<div>").html(tmpl) |
62 |
| - select = div.find("select") |
| 60 | + ''' |
| 61 | + div = $('<div>').html(tmpl) |
| 62 | + select = div.find('select') |
63 | 63 | expect(select.size()).toBe(1)
|
64 | 64 | select.chosen()
|
65 |
| - placeholder = div.find(".chosen-single > span") |
66 |
| - expect(placeholder.text()).toBe("<None>") |
| 65 | + placeholder = div.find('.chosen-single > span') |
| 66 | + expect(placeholder.text()).toBe('<None>') |
67 | 67 |
|
68 |
| - describe "disabled fieldset", -> |
| 68 | + describe 'disabled fieldset', -> |
69 | 69 |
|
70 |
| - it "should render as disabled", -> |
71 |
| - tmpl = " |
| 70 | + it 'should render as disabled', -> |
| 71 | + tmpl = ''' |
72 | 72 | <fieldset disabled>
|
73 |
| - <select data-placeholder='Choose a Country...'> |
74 |
| - <option value=''></option> |
75 |
| - <option value='United States'>United States</option> |
76 |
| - <option value='United Kingdom'>United Kingdom</option> |
77 |
| - <option value='Afghanistan'>Afghanistan</option> |
| 73 | + <select data-placeholder="Choose a Country..."> |
| 74 | + <option value=""></option> |
| 75 | + <option value="United States">United States</option> |
| 76 | + <option value="United Kingdom">United Kingdom</option> |
| 77 | + <option value="Afghanistan">Afghanistan</option> |
78 | 78 | </select>
|
79 | 79 | </fieldset>
|
80 |
| - " |
81 |
| - div = $("<div>").html(tmpl) |
82 |
| - select = div.find("select") |
| 80 | + ''' |
| 81 | + div = $('<div>').html(tmpl) |
| 82 | + select = div.find('select') |
83 | 83 | expect(select.size()).toBe(1)
|
84 | 84 | select.chosen()
|
85 | 85 |
|
86 |
| - container = div.find(".chosen-container") |
87 |
| - expect(container.hasClass("chosen-disabled")).toBe true |
| 86 | + container = div.find('.chosen-container') |
| 87 | + expect(container.hasClass('chosen-disabled')).toBe true |
0 commit comments