Sha256: db4cde89377209293a4975c10981312399ca27fd0b1f4c81e56cbfeb98a4efc8

Contents?: true

Size: 1.8 KB

Versions: 12

Compression:

Stored size: 1.8 KB

Contents

describe 'up.syntax', ->
  
  describe 'Javascript functions', ->
  
    describe 'up.compiler', ->
      
      it 'applies an event initializer whenever a matching fragment is inserted', ->
  
        observeClass = jasmine.createSpy()
        up.compiler '.child', ($element) ->
          observeClass($element.attr('class'))
  
        up.hello(affix('.container .child'))
   
        expect(observeClass).not.toHaveBeenCalledWith('container')
        expect(observeClass).toHaveBeenCalledWith('child')           
  
      it 'lets allows initializers return a destructor function, which is called when a compiled fragment gets destroyed', ->
  
        destructor = jasmine.createSpy()
        up.compiler '.child', ($element) ->
          destructor
  
        up.hello(affix('.container .child'))
        expect(destructor).not.toHaveBeenCalled()
        
        up.destroy('.container')
        expect(destructor).toHaveBeenCalled()

      it 'parses an up-data attribute as JSON and passes the parsed object as a second argument to the initializer', ->

        observeArgs = jasmine.createSpy()
        up.compiler '.child', ($element, data) ->
          observeArgs($element.attr('class'), data)

        data = { key1: 'value1', key2: 'value2' }

        $tag = affix(".child").attr('up-data', JSON.stringify(data))
        up.hello($tag)

        expect(observeArgs).toHaveBeenCalledWith('child', data)

      it 'passes an empty object as a second argument to the initializer if there is no up-data attribute', ->

        observeArgs = jasmine.createSpy()
        up.compiler '.child', ($element, data) ->
          observeArgs($element.attr('class'), data)

        up.hello(affix(".child"))

        expect(observeArgs).toHaveBeenCalledWith('child', {})


    describe 'up.hello', ->

      it 'should have tests'
      
     

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
upjs-rails-0.18.1 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.18.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.17.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.16.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.15.1 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.15.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.14.1 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.14.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.13.0 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.12.5 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.12.4 spec_app/spec/javascripts/up/syntax_spec.js.coffee
upjs-rails-0.12.3 spec_app/spec/javascripts/up/syntax_spec.js.coffee