Permalink
Browse files

add basic tests for Rickshaw.Class

  • Loading branch information...
1 parent 36b44d9 commit 76f1cc53fd7fb130e32848a0b3f137bafa20a76e @dchester dchester committed Mar 11, 2012
Showing with 53 additions and 0 deletions.
  1. +53 −0 tests/Rickshaw.Class.js
View
@@ -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();
+};

0 comments on commit 76f1cc5

Please sign in to comment.