class.test.js
1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require("should");
var Class = require('../lib/class.js');
describe('Mode Parser', function() {
it('should parse 0777',function() {
var Person = Class.extend({
init: function(isDancing){
this.dancing = isDancing;
},
dance: function(){
return this.dancing;
}
});
var Ninja = Person.extend({
init: function(){
this._super( false );
},
dance: function(){
// Call the inherited version of dance()
return this._super();
},
swingSword: function(){
return true;
}
});
var p = new Person(true);
p.dance().should.be.true;
var n = new Ninja();
n.dance().should.be.false;
n.swingSword().should.be.true;
// Should all be true
(p instanceof Person).should.be.true;
(p instanceof Class).should.be.true;
(n instanceof Ninja).should.be.true;
(n instanceof Person).should.be.true;
(n instanceof Class).should.be.true;
});
});