diff --git a/spec/jquery/basic.spec.coffee b/spec/jquery/basic.spec.coffee index cbb78589548..3615cdd8574 100644 --- a/spec/jquery/basic.spec.coffee +++ b/spec/jquery/basic.spec.coffee @@ -1,87 +1,87 @@ -describe "Basic setup", -> - it "should add chosen to jQuery object", -> +describe 'Basic setup', -> + it 'should add chosen to jQuery object', -> expect(jQuery.fn.chosen).toBeDefined() - it "should create very basic chosen", -> - tmpl = " - + + + + - " - div = $("
").html(tmpl) - select = div.find("select") + ''' + div = $('
').html(tmpl) + select = div.find('select') expect(select.size()).toBe(1) select.chosen() # very simple check that the necessary elements have been created - ["container", "container-single", "single", "default"].forEach (clazz)-> + ['container', 'container-single', 'single', 'default'].forEach (clazz)-> el = div.find(".chosen-#{clazz}") expect(el.size()).toBe(1) # test a few interactions - expect(select.val()).toBe "" + expect(select.val()).toBe '' - container = div.find(".chosen-container") - container.trigger("mousedown") # open the drop - expect(container.hasClass("chosen-container-active")).toBe true + container = div.find('.chosen-container') + container.trigger('mousedown') # open the drop + expect(container.hasClass('chosen-container-active')).toBe true #select an item - container.find(".active-result").last().trigger("mouseup") + container.find('.active-result').last().trigger('mouseup') - expect(select.val()).toBe "Afghanistan" + expect(select.val()).toBe 'Afghanistan' - describe "data-placeholder", -> + describe 'data-placeholder', -> - it "should render", -> - tmpl = " - + + + + - " - div = $("
").html(tmpl) - select = div.find("select") + ''' + div = $('
').html(tmpl) + select = div.find('select') expect(select.size()).toBe(1) select.chosen() - placeholder = div.find(".chosen-single > span") - expect(placeholder.text()).toBe("Choose a Country...") + placeholder = div.find('.chosen-single > span') + expect(placeholder.text()).toBe('Choose a Country...') - it "should render with special characters", -> - tmpl = " - + + + + - " - div = $("
").html(tmpl) - select = div.find("select") + ''' + div = $('
').html(tmpl) + select = div.find('select') expect(select.size()).toBe(1) select.chosen() - placeholder = div.find(".chosen-single > span") - expect(placeholder.text()).toBe("") + placeholder = div.find('.chosen-single > span') + expect(placeholder.text()).toBe('') - describe "disabled fieldset", -> + describe 'disabled fieldset', -> - it "should render as disabled", -> - tmpl = " + it 'should render as disabled', -> + tmpl = '''
- + + + +
- " - div = $("
").html(tmpl) - select = div.find("select") + ''' + div = $('
').html(tmpl) + select = div.find('select') expect(select.size()).toBe(1) select.chosen() - container = div.find(".chosen-container") - expect(container.hasClass("chosen-disabled")).toBe true + container = div.find('.chosen-container') + expect(container.hasClass('chosen-disabled')).toBe true diff --git a/spec/jquery/events.spec.coffee b/spec/jquery/events.spec.coffee index b6756048e85..2e27c440234 100644 --- a/spec/jquery/events.spec.coffee +++ b/spec/jquery/events.spec.coffee @@ -1,19 +1,19 @@ -describe "Events", -> - it "chosen should fire the right events", -> - tmpl = " - + + + + - " - div = $("
").html(tmpl) - select = div.find("select") + ''' + div = $('
').html(tmpl) + select = div.find('select') expect(select.size()).toBe(1) select.chosen() # very simple check that the necessary elements have been created - ["container", "container-single", "single", "default"].forEach (clazz)-> + ['container', 'container-single', 'single', 'default'].forEach (clazz)-> el = div.find(".chosen-#{clazz}") expect(el.size()).toBe(1) @@ -21,10 +21,10 @@ describe "Events", -> event_sequence = [] div.on 'input change', (evt) -> event_sequence.push evt.type - container = div.find(".chosen-container") - container.trigger("mousedown") # open the drop - expect(container.hasClass("chosen-container-active")).toBe true + container = div.find('.chosen-container') + container.trigger('mousedown') # open the drop + expect(container.hasClass('chosen-container-active')).toBe true #select an item - container.find(".active-result").last().trigger("mouseup") + container.find('.active-result').last().trigger('mouseup') expect(event_sequence).toEqual ['input', 'change'] diff --git a/spec/jquery/max_shown_results.spec.coffee b/spec/jquery/max_shown_results.spec.coffee index e37cb23b475..bcc5c8ebab6 100644 --- a/spec/jquery/max_shown_results.spec.coffee +++ b/spec/jquery/max_shown_results.spec.coffee @@ -1,64 +1,64 @@ -describe "search", -> - it "should display only matching items when entering a search term", -> - tmpl = " - - " - div = $("
").html(tmpl) - select = div.find("select") +describe 'search', -> + it 'should display only matching items when entering a search term', -> + tmpl = ''' + + ''' + div = $('
').html(tmpl) + select = div.find('select') select.chosen() - container = div.find(".chosen-container") - container.trigger("mousedown") # open the drop + container = div.find('.chosen-container') + container.trigger('mousedown') # open the drop # Expect all results to be shown - results = div.find(".active-result") + results = div.find('.active-result') expect(results.size()).toBe(3) # Enter some text in the search field. - search_field = div.find(".chosen-search input").first() - search_field.val("Afgh") + search_field = div.find('.chosen-search input').first() + search_field.val('Afgh') search_field.trigger('keyup') # Expect to only have one result: 'Afghanistan'. - results = div.find(".active-result") + results = div.find('.active-result') expect(results.size()).toBe(1) - expect(results.first().text()).toBe "Afghanistan" + expect(results.first().text()).toBe 'Afghanistan' - it "should only show max_shown_results items in results", -> - tmpl = " - - " - div = $("
").html(tmpl) - select = div.find("select") + it 'should only show max_shown_results items in results', -> + tmpl = ''' + + ''' + div = $('
').html(tmpl) + select = div.find('select') select.chosen({max_shown_results: 1 }) - container = div.find(".chosen-container") - container.trigger("mousedown") # open the drop - results = div.find(".active-result") + container = div.find('.chosen-container') + container.trigger('mousedown') # open the drop + results = div.find('.active-result') expect(results.size()).toBe(1) # Enter some text in the search field. - search_field = div.find(".chosen-search input").first() - search_field.val("United") - search_field.trigger("keyup") + search_field = div.find('.chosen-search input').first() + search_field.val('United') + search_field.trigger('keyup') # Showing only one result: the one that occurs first. - results = div.find(".active-result") + results = div.find('.active-result') expect(results.size()).toBe(1) - expect(results.first().text()).toBe "United States" + expect(results.first().text()).toBe 'United States' # Showing still only one result, but not the first one. - search_field.val("United Ki") - search_field.trigger("keyup") - results = div.find(".active-result") + search_field.val('United Ki') + search_field.trigger('keyup') + results = div.find('.active-result') expect(results.size()).toBe(1) - expect(results.first().text()).toBe "United Kingdom" + expect(results.first().text()).toBe 'United Kingdom' diff --git a/spec/proto/basic.spec.coffee b/spec/proto/basic.spec.coffee index 9e7212a57b9..f0f967d4a80 100644 --- a/spec/proto/basic.spec.coffee +++ b/spec/proto/basic.spec.coffee @@ -1,101 +1,100 @@ -describe "Basic setup", -> - it "should add expose a Chosen global", -> +describe 'Basic setup', -> + it 'should expose a Chosen global', -> expect(Chosen).toBeDefined() - it "should create very basic chosen", -> - tmpl = " - + + + + - " - - div = new Element("div") + ''' + div = new Element('div') document.body.insert(div) div.update(tmpl) - select = div.down("select") + select = div.down('select') expect(select).toBeDefined() new Chosen(select) # very simple check that the necessary elements have been created - ["container", "container-single", "single", "default"].forEach (clazz)-> + ['container', 'container-single', 'single', 'default'].forEach (clazz)-> el = div.down(".chosen-#{clazz}") expect(el).toBeDefined() # test a few interactions - expect($F(select)).toBe "" + expect($F(select)).toBe '' - container = div.down(".chosen-container") - simulant.fire(container, "mousedown") # open the drop - expect(container.hasClassName("chosen-container-active")).toBe true + container = div.down('.chosen-container') + simulant.fire(container, 'mousedown') # open the drop + expect(container.hasClassName('chosen-container-active')).toBe true - #select an item - result = container.select(".active-result").last() - simulant.fire(result, "mouseup") + # select an item + result = container.select('.active-result').last() + simulant.fire(result, 'mouseup') - expect($F(select)).toBe "Afghanistan" + expect($F(select)).toBe 'Afghanistan' div.remove() - describe "data-placeholder", -> + describe 'data-placeholder', -> - it "should render", -> - tmpl = " - + + + + - " - div = new Element("div") + ''' + div = new Element('div') document.body.insert(div) div.update(tmpl) - select = div.down("select") + select = div.down('select') expect(select).toBeDefined() new Chosen(select) - placeholder = div.down(".chosen-single > span") - expect(placeholder.innerText).toBe("Choose a Country...") + placeholder = div.down('.chosen-single > span') + expect(placeholder.innerText).toBe('Choose a Country...') - it "should render with special characters", -> - tmpl = " - + + + + - " - div = new Element("div") + ''' + div = new Element('div') document.body.insert(div) div.update(tmpl) - select = div.down("select") + select = div.down('select') expect(select).toBeDefined() new Chosen(select) - placeholder = div.down(".chosen-single > span") - expect(placeholder.innerText).toBe("") + placeholder = div.down('.chosen-single > span') + expect(placeholder.innerText).toBe('') - describe "disabled fieldset", -> + describe 'disabled fieldset', -> - it "should render as disabled", -> - tmpl = " + it 'should render as disabled', -> + tmpl = '''
- + + + +
- " - div = new Element("div") + ''' + div = new Element('div') document.body.insert(div) div.update(tmpl) - select = div.down("select") + select = div.down('select') expect(select).toBeDefined() new Chosen(select) - container = div.down(".chosen-container") - expect(container.hasClassName("chosen-disabled")).toBe true + container = div.down('.chosen-container') + expect(container.hasClassName('chosen-disabled')).toBe true diff --git a/spec/proto/events.spec.coffee b/spec/proto/events.spec.coffee index 125da54e665..55524c4700b 100644 --- a/spec/proto/events.spec.coffee +++ b/spec/proto/events.spec.coffee @@ -1,19 +1,19 @@ -describe "Events", -> - it "chosen should fire the right events", -> - tmpl = " - + + + + - " + ''' - div = new Element("div") + div = new Element('div') document.body.insert(div) div.update(tmpl) - select = div.down("select") + select = div.down('select') expect(select).toBeDefined() new Chosen(select) @@ -21,13 +21,13 @@ describe "Events", -> document.addEventListener 'input', -> event_sequence.push 'input' document.addEventListener 'change', -> event_sequence.push 'change' - container = div.down(".chosen-container") - simulant.fire(container, "mousedown") # open the drop - expect(container.hasClassName("chosen-container-active")).toBe true + container = div.down('.chosen-container') + simulant.fire(container, 'mousedown') # open the drop + expect(container.hasClassName('chosen-container-active')).toBe true - #select an item - result = container.select(".active-result").last() - simulant.fire(result, "mouseup") + # select an item + result = container.select('.active-result').last() + simulant.fire(result, 'mouseup') expect(event_sequence).toEqual ['input', 'change'] div.remove()