Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
require('../src/js/Rickshaw'); | |||
require('../src/js/Rickshaw.Class'); | |||
|
|||
exports.load = function(test) { | |||
|
|||
test.equal(typeof Rickshaw.Class, 'object', 'Rickshaw.Class is a function'); | |||
test.done(); | |||
}; | |||
|
|||
exports.instantiation = function(test) { | |||
|
|||
Rickshaw.namespace('Rickshaw.Sample.Class'); | |||
|
|||
Rickshaw.Sample.Class = Rickshaw.Class.create({ | |||
name: 'sample', | |||
concat: function(suffix) { | |||
return [this.name, suffix].join(' '); | |||
} | |||
}); | |||
|
|||
var sample = new Rickshaw.Sample.Class(); | |||
test.equal(sample.concat('polka'), 'sample polka'); | |||
|
|||
Rickshaw.namespace('Rickshaw.Sample.Class.Prefix'); | |||
|
|||
Rickshaw.Sample.Subclass = Rickshaw.Class.create( Rickshaw.Sample.Class, { | |||
name: 'sampler', | |||
}); | |||
|
|||
var sampler = new Rickshaw.Sample.Subclass(); | |||
test.equal(sampler.concat('polka'), 'sampler polka'); | |||
|
|||
test.done(); | |||
}; | |||
|
|||
exports.array = function(test) { | |||
|
|||
Rickshaw.namespace('Rickshaw.Sample.Array'); | |||
|
|||
Rickshaw.Sample.Array = Rickshaw.Class.create(Array, { | |||
second: function() { | |||
return this[1]; | |||
} | |||
}); | |||
|
|||
var array = new Rickshaw.Sample.Array(); | |||
array.push('red'); | |||
array.push('blue'); | |||
|
|||
test.equal(array.second(), 'blue'); | |||
|
|||
test.done(); | |||
}; |