Login   Register  
Icontem

File: test/getKeys.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Javier Camelis  >  JavaScript Multi Key Array  >  test/getKeys.js  >  Download  
File: test/getKeys.js
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: JavaScript Multi Key Array
Set and get values from arrays using multiple keys
Author: By
Last change:
Date: 2013-04-26 08:21
Size: 889 bytes
 

Contents

Class file image Download
module("getKeys Test Module.");
test( "getKeys First Level", function() {
	var map = MultiKey();
	
	var firstKeyArray = ['foo1', 'foo2', 'foo3'];
	
	var firstKey1 = firstKeyArray[0];
	var firstKey2 = firstKeyArray[1];
	var firstKey3 = firstKeyArray[2];

	map.set([firstKey1, 'var1'], 'test0');
	map.set([firstKey2, 'var2'], 'test1');
	map.set([firstKey3, 'var3'], 'test2');

	deepEqual(map.getKeys(), firstKeyArray, "Passed!");
});
test( "getKeys Second Level", function() {
	var map = MultiKey();
	
	var secondKeyArray = ['foo1', 'foo2', 'foo3'];
	
	var firstKey = 'foo';
	var secondKey1 = secondKeyArray[0];
	var secondKey2 = secondKeyArray[1];
	var secondKey3 = secondKeyArray[2];

	map.set([firstKey, secondKey1], 'test0');
	map.set([firstKey, secondKey2], 'test1');
	map.set([firstKey, secondKey3], 'test2');

	deepEqual(map.get(firstKey).getKeys(), secondKeyArray, "Passed!");
});