Sha256: db6a6746681c7ad63bc961f897aa7f7b8d4b3843d7e2620b1c8a1528989cf546
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
describe 'Base', -> describe 'class functions', -> beforeEach -> initSpy = jasmine.createSpy('initSpy') @initSpy = initSpy class MyClass extends Streusel.Base constructor: (el) -> initSpy() super(el) @subject = 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
3 entries across 3 versions & 1 rubygems