Sha256: c9c3231d8b31ccdd7f35495ee21d118abc30aa9ba66437f3a01bef178d952e22

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

require 'observable/vendor/shims/accessors.js'

$ = require 'jquery'

describe 'Object #defineProperty',  ->

  describe 'on dom elements', ->
    spy = object = null

    beforeEach ->
      object = document.createElement 'domo'
      document.body.appendChild object
      spy = sinon.spy()


    it 'should define property', (done) ->
      Object.defineProperty object, 'kun', {}

    it 'should define property getter', (done) ->
      getter = sinon.stub().returns(42)

      Object.defineProperty object, 'kun',
        get: getter

      expect(object.kun + 1).toBe 43
      expect(getter.called).toBe true

    it 'should define property setter', (done) ->

      Object.defineProperty object, 'kun',
        set: spy

      object.kun = 10

      expect(spy.calledWith 10).toBe true

  describe 'off dom elements', ->

    beforeEach ->
      @object = {}
      @spy = sinon.spy()

    # it's simply not possible
    it 'should not define property setter', (done) ->
      expect( =>
        Object.defineProperty @object, 'kun',
          set: @spy
      ).toThrow()


    it 'should define property getter', (done) ->
      getter = sinon.stub().returns(42)

      Object.defineProperty @object, 'kun',
        get: getter

      expect(@object.kun + 1).toBe 43
      expect(getter.called).toBe true

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ende-0.4.25 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.24 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.23 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.22 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.21 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.15 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.14 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.13 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.12 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.11 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.10 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.9 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.8 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.7 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee
ende-0.4.6 vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee