describe "jasmine.fixture", -> EXAMPLES = [ 'article' #
'.foo' #
'.foo-hah' #
'#blah-blah' #
'#baz' #
'h1.foo' #

'h2#baz' #

'h3#zing.zoom' #

'h4.zoom#zing' #

'div span ul li' #
'a b c d e f g h i j k l m n o p q r s t u v w x y z' #

'.boom.bang.pow#whoosh' #
'#foo .panda' #
'input#man .restroom' # '.pants.zipper' #
'foo > bar > baz' # 'input[value="12"]' # 'div[class="class1 class2 class3"] span[div="div1 div2 div3"]' #
'form fieldset[name=ok] input#foo.sp1.sp1[foo="woo"][value="13"]' #
'[name="foo"][bar="baz"]' # 'div[data-bind="my_item"]' #
'.ui-dialog[style="width: 1px; height: 5px"]' #
'#toddler .hidden.toy input[name="toyName"][value="cuddle bunny"]' #
'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