Skip to content

Commit

Permalink
cleanup, up cov
Browse files Browse the repository at this point in the history
  • Loading branch information
scttdavs committed Apr 5, 2016
1 parent 86ad6e1 commit e9af204
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
8 changes: 2 additions & 6 deletions klassy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
return key;
};

var isFunction = function(obj) {
return typeof obj === 'function';
};

var isNotConstructor = function(key) {
return key !== CONSTRUCTOR;
};
Expand Down Expand Up @@ -91,9 +87,9 @@

while ((proto = Object.getPrototypeOf(proto))) {
if (!proto[name]) {
continue;
continue;
} else if (proto[name]) {
return proto[name].apply(this, args);
return proto[name].apply(this, args);
}
}

Expand Down
35 changes: 18 additions & 17 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict;'
"use strict";

var chai = require("chai");
var expect = chai.expect;
Expand Down Expand Up @@ -52,35 +52,35 @@ var Bulldog = Dog.extend({
this.name = name;
this.breed = "Bulldog";
},
getCapsName: function() {
return this.super("getCapsName");
getCapsName: function(name) {
return this.super(name);
}
});

var george = new Bulldog("George");
var lassie = new Dog("Lassie", "Collie");
var bill = new Person("Bill");
var person = new Person();


describe("Basics", function() {
it("should create a default", function() {
var Person = klassy();
var bill = new Person();

expect(Person).to.be.a("function");
expect(bill).to.be.an("object");
});

it("should create a klass", function() {
var bill = new Person("Bill");
var person = new Person();

it("should create a klass", function() {
expect(bill.say()).to.equal("Bill");
expect(person.say()).to.equal("Person");
});
});

describe("Static Methods", function() {
it("should save a static method", function() {
var bill = new Person("Bill");
expect(bill.talk).to.be.undefined;
expect(Person.talk()).to.equal("static")
expect(Person.talk()).to.equal("static");
});
});

Expand All @@ -98,16 +98,12 @@ describe("Subclassing", function() {
});

it("should extend another klass with overrides/new methods", function() {
var lassie = new Dog("Lassie", "Collie");

expect(Dog.say()).to.equal("animal");
expect(lassie.say).to.be.undefined;
expect(lassie.getBreed()).to.equal("Collie");
});

it("should extend more than one klass", function() {
var george = new Bulldog("George");

expect(Bulldog.say()).to.equal("animal");
expect(george.getName()).to.equal("George");
expect(george.getBreed()).to.equal("Bulldog");
Expand All @@ -116,9 +112,14 @@ describe("Subclassing", function() {

describe("Super", function() {
it("should work with super", function() {
var george = new Bulldog("George");

expect(Bulldog.say()).to.equal("animal");
expect(george.getCapsName()).to.equal("GEORGE");
expect(george.getCapsName("getCapsName")).to.equal("GEORGE");
});

it("should throw an error when no super is found", function() {
var curry = function() {
george.getCapsName();
}
expect(curry).to.throw("no `super` method was found!");
});
});

0 comments on commit e9af204

Please sign in to comment.