Sha256: 1e92d4b55f0bc67e2dcb9fe861fd34b773eca6333d609b0e7df7494d6b134f6f
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
describe 'Base', -> describe 'class functions', -> beforeEach -> Streusel.selectorPrefix = undefined Streusel.selectorType = undefined initSpy = jasmine.createSpy('initSpy') @initSpy = initSpy class MyClass extends Streusel.Base @className = 'MyClass' constructor: (el) -> initSpy() super(el) @subject = MyClass it 'computes selector based on class name', -> Streusel.selectorPrefix = 'js' Streusel.selectorType = 'css_class' expect(@subject.selector()).toEqual('.js-myclass') it 'computes selector based on class name', -> expect(@subject.selector()).toEqual('[data-streusel-myclass]') it 'assigns object to tags', -> tag1 = affix('#c1[data-streusel-myclass]') tag2 = affix('#c2[data-streusel-myclass]') objects = @subject.init() expect(objects).toBeDefined() expect(objects.length).toEqual(2) expect(objects[0]).toBeDefined() expect(tag1.data('object')).toBeDefined() expect(tag1.data('object')).toEqual(objects[0]) expect(tag2.data('object')).toBeDefined() expect(tag2.data('object')).toEqual(objects[1]) it 'does not double initialize objects', -> tag1 = affix('#c1[data-streusel-myclass]') objects = @subject.init() expect(objects.length).toEqual(1) expect(@initSpy).toHaveBeenCalled() @initSpy.reset() spyOn(Streusel, 'Base') objects = @subject.init() expect(objects.length).toEqual(0) expect(@initSpy).not.toHaveBeenCalled()
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
partystreusel-1.1.0pre2 | spec/javascripts/partystreusel/base_spec.js.coffee |
partystreusel-1.1.0pre1 | spec/javascripts/partystreusel/base_spec.js.coffee |