Sha256: d31094ed94760a5723d8e83bf2a3a319becb3baf3a17bb16aa849271bb7edb4f
Contents?: true
Size: 1.58 KB
Versions: 46
Compression:
Stored size: 1.58 KB
Contents
describe "Joosy.Module", -> it "should track inheritance", -> class A class B extends A class C extends B class D for a in [A, B, C, D] for b in [A, B, C, D] if (a == b) || ((a == B) && (b == A)) || ((a == C) && (b != D)) expect(Joosy.Module.hasAncestor.apply(null, [a, b])).toBeTruthy() else expect(Joosy.Module.hasAncestor.apply(null, [a, b])).toBeFalsy() it "should include properties into prototype", -> TestModule = property: 'value' class Klass extends Joosy.Module @include TestModule expect(Klass::property).toEqual 'value' expect((new Klass()).property).toEqual 'value' it "should extend object", -> TestModule = property: 'value' class Klass extends Joosy.Module @extend TestModule expect(Klass.property).toEqual 'value' expect((new Klass()).property).toBeUndefined() it "should run callbacks on include and extend", -> TestModule = property: 'value' included: sinon.spy() extended: sinon.spy() class Klass extends Joosy.Module @include TestModule @extend TestModule for callback in ['included', 'extended'] expect(TestModule[callback].callCount).toEqual 1 expect(TestModule[callback].getCall(0).calledOn(Klass)).toBeTruthy() it "should have minimal set of properties", -> expect(Object.extended(Joosy.Module).keys()).toEqual ['__namespace__', '__className', 'hasAncestor', 'alias', 'aliasStatic', 'merge', 'include', 'extend'] expect(Object.extended(Joosy.Module.prototype).keys()).toEqual []
Version data entries
46 entries across 46 versions & 1 rubygems