Skip to content

Commit

Permalink
Fix Table Specs in node.js and they are using Jasmine now
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian committed Apr 15, 2011
1 parent c661e1f commit a23401d
Showing 1 changed file with 42 additions and 43 deletions.
85 changes: 42 additions & 43 deletions Specs/1.3/Utilities/Table.js
@@ -1,56 +1,55 @@
/*
Script: Hash.Cookie.js
Specs for Hash.Cookie.js
Script: Table.js
Specs for Table.js
License:
MIT-style license.
*/

(function(){
describe('Table', function(){

var table = new Table();
var one = 1;
var obj = {};
var fn = function(){};

describe('Table', {

'Adds a values to a Table instance': function(){
expect(table.length).toEqual(0);
table.set('foo', 'bar');
expect(table.length).toEqual(1);
table.set(one, 'one');
table.set(document.body, 'doc body');
table.set(obj, 'an object');
expect(table.get('foo')).toEqual('bar');
expect(table.get(one)).toEqual('one');
expect(table.get(document.body)).toEqual('doc body');
expect(table.get(obj)).toEqual('an object');
expect(table.length).toEqual(4);
},

'Iterates over a Table instance': function(){
var keys = [];
var values = [];
table.each(function(key, val){
keys.push(key);
values.push(val);
});
expect(keys).toEqual(['foo', one, document.body, obj]);
expect(values).toEqual(['bar', 'one', 'doc body', 'an object']);
},
it('Adds a values to a Table instance', function(){
expect(table.length).toEqual(0);
table.set('foo', 'bar');
expect(table.length).toEqual(1);
table.set(one, 'one');
table.set(fn, 'function');
table.set(obj, 'an object');
expect(table.get('foo')).toEqual('bar');
expect(table.get(one)).toEqual('one');
expect(table.get(fn)).toEqual('function');
expect(table.get(obj)).toEqual('an object');
expect(table.length).toEqual(4);
});

'Removes values from a Table instance': function(){
expect(table.length).toEqual(4);
table.erase('foo');
expect(table.length).toEqual(3);
table.erase(one);
table.erase(document.body);
table.erase(obj);
expect(table.get('foo')).toEqual(null);
expect(table.get(one)).toEqual(null);
expect(table.get(document.body)).toEqual(null);
expect(table.get(obj)).toEqual(null);
expect(table.length).toEqual(0);
}
it('Iterates over a Table instance', function(){
var keys = [];
var values = [];
table.each(function(key, val){
keys.push(key);
values.push(val);
});
expect(keys).toEqual(['foo', one, fn, obj]);
expect(values).toEqual(['bar', 'one', 'function', 'an object']);
});

it('Removes values from a Table instance', function(){
expect(table.length).toEqual(4);
table.erase('foo');
expect(table.length).toEqual(3);
table.erase(one);
table.erase(fn);
table.erase(obj);
expect(table.get('foo')).toEqual(null);
expect(table.get(one)).toEqual(null);
expect(table.get(fn)).toEqual(null);
expect(table.get(obj)).toEqual(null);
expect(table.length).toEqual(0);
});
})();

});

0 comments on commit a23401d

Please sign in to comment.