Sha256: f04de91674d64d6d072c19105336894f47fae8c84ed45bfd47cfcdcd6faf8d12

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

/*
---
name: Table Tests
requires: [More/Table]
provides: [Table.Tests]
license: MIT-style license.
...
*/

describe('Table', function(){

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

	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);
	});

	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);
	});

});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1.5 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1.4 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1.3 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1.2 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1.1 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js
lsd_rails-0.1 Packages/mootools-more/Tests/Specs/1.3/Utilities/Table.js