1 describe("Class", function() {
3 describe("#extend", function() {
8 beforeEach(function() {
9 constructor = jasmine
.createSpy(),
10 method
= jasmine
.createSpy();
12 Klass
= L
.Class
.extend({
14 includes
: {mixin
: true},
16 initialize
: constructor,
22 it("should create a class with the given constructor & properties", function() {
25 expect(constructor).toHaveBeenCalled();
26 expect(a
.foo
).toEqual(5);
30 expect(method
).toHaveBeenCalled();
33 it("should inherit parent classes' constructor & properties", function() {
34 var Klass2
= Klass
.extend({baz
: 2});
38 expect(b
instanceof Klass
).toBeTruthy();
39 expect(b
instanceof Klass2
).toBeTruthy();
41 expect(constructor).toHaveBeenCalled();
42 expect(b
.baz
).toEqual(2);
46 expect(method
).toHaveBeenCalled();
49 it("should grant the ability to call parent methods, including constructor", function() {
50 var Klass2
= Klass
.extend({
51 initialize: function() {},
57 expect(constructor).not
.toHaveBeenCalled();
58 b
.superclass
.initialize
.call(this);
59 expect(constructor).toHaveBeenCalled();
61 b
.superclass
.bar
.call(this);
62 expect(method
).toHaveBeenCalled();
65 it("should support static properties", function() {
66 expect(Klass
.bla
).toEqual(1);
69 it("should inherit parent static properties", function() {
70 var Klass2
= Klass
.extend({});
72 expect(Klass2
.bla
).toEqual(1);
75 it("should include the given mixin", function() {
77 expect(a
.mixin
).toBeTruthy();
80 it("should be able to include multiple mixins", function() {
81 var Klass2
= L
.Class
.extend({
82 includes
: [{mixin
: true}, {mixin2
: true}]
86 expect(a
.mixin
).toBeTruthy();
87 expect(a
.mixin2
).toBeTruthy();
90 it("should grant the ability to include the given mixin", function() {
91 Klass
.include({mixin2
: true});
94 expect(a
.mixin2
).toBeTruthy();
97 it("should merge options instead of replacing them", function() {
98 var KlassWithOptions1
= L
.Class
.extend({
104 var KlassWithOptions2
= KlassWithOptions1
.extend({
111 var a
= new KlassWithOptions2();
113 expect(a
.options
).toEqual({