UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

34 lines (29 loc) 1.09 kB
test "Binding dimensions-related properties of the window should not overwrite the property descriptor and should not disable their functionality", ()-> if not isBrowser then @skip() else targetKeys = [ 'innerWidth' 'innerHeight' 'outerWidth' 'outerHeight' 'scrollX' 'scrollY' 'pageXOffset' 'pageYOffset' 'screenX' 'screenY' 'screenLeft' 'screenTop' ] oringalDescs = {} for key in targetKeys originalValue = window[key] oringalDescs[key] = Object.getOwnPropertyDescriptor(window, key) expect(Object.getOwnPropertyDescriptor(window, key), key).to.eql(oringalDescs[key]) SimplyBind(key).of(window) expect(Object.getOwnPropertyDescriptor(window, key), key).to.eql(oringalDescs[key]) expect(window[key], key).to.equal(originalValue) unless document.body.offsetHeight < window.innerHeight window.scrollTo(0, 0) expect(window.scrollY, 'window Y scroll').to.equal(0) newScroll = Math.floor (document.body.offsetHeight - window.innerHeight) / 2 window.scrollTo(0, newScroll) expect(window.scrollY, 'window Y scroll').to.equal(newScroll)