'select[name="date[year]"]' #
'input[name="some[thing][foo]"]'
'input[type="text"][value="4.99"][class="class-name"]'
]
describe ".affix", ->
for selector in EXAMPLES
do (selector) ->
describe "#{selector} working", ->
Then -> expect(selector).toInjectProperly()
Then -> expect($('body')).not.toHas(selector) #<--ensure no pollution is happening
context "non-ids with hash symbol", ->
Given -> affix('a[data-target-pane="#pane-id"]')
Then -> expect($('body')).not.toHas('#pane-id')
context "text node with space char", ->
Given -> affix('a.link{Text With Space}')
Then -> expect($('.link').text()).toEqual('Text With Space')
describe ".create", ->
Given -> @subject = jasmine.fixture
for selector in EXAMPLES
do (selector) ->
describe "#{selector} working", ->
When -> @$result = @subject.create(selector)
Then -> @$result.length > 0
And -> @$result.parent().length == 0
And -> expect($('body')).not.toHas(selector)
context "a plain old div", ->
When -> @$result = @subject.create('div')
Then -> expect(@$result).toIs('div')
context "raw attrs", ->
When -> @$result = @subject.create('[name=foo]')
Then -> expect(@$result).toIs('[name=foo]')
context "nesting returns", ->
When -> @$result = @subject.create('table.sp_record tbody tr')
Then -> expect(@$result).toIs('table')
context "a siblings!", ->
When -> @$result = @subject.create('div h1+h2')
Then -> expect(@$result.find('h1').siblings('h2')).toIs("h2")
context "chaining", ->
When -> @$container = @subject.create('.container')
When -> @$result = @$container.affix('#content')
Then -> expect(@$container).toHas('#content')
And -> expect(@$result).toIs('#content')
context "text node with space char", ->
Given -> @result = @subject.create('a.link{Text With Space}')
Then -> @result.find('With').length == 0