Last active
December 15, 2015 11:39
-
-
Save danshearmur/5254619 to your computer and use it in GitHub Desktop.
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
define(['hashmap'], function (HashMap) { | |
describe('HashMap', function () { | |
var hash; | |
function size (obj) { | |
var size = 0; | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) size++; | |
} | |
return size; | |
} | |
beforeEach(function () { | |
hash = new HashMap(); | |
}); | |
it('should be an instanceof the HashMap class', function () { | |
assert(hash instanceof HashMap); | |
}); | |
it('should have an array to store the hash in', function () { | |
hash.data.should.be.an('array'); | |
}); | |
it('should have a length', function () { | |
hash.length.should.be.a('number'); | |
}); | |
it('hash should have an add function', function () { | |
hash.add.should.be.a('function'); | |
}); | |
it('hash should have a get function', function () { | |
hash.get.should.be.a('function'); | |
}); | |
it('hash data\'s size should grow when item is added', function () { | |
var sizeBefore = size(hash.data); | |
hash.add('test-field', 'test text'); | |
var sizeAfter = size(hash.data); | |
sizeAfter.should.equal(sizeBefore + 1); | |
}); | |
it('hash should return the same item you put in', function () { | |
var testText = 'testing testing 123'; | |
var key = 'test'; | |
hash.add(key, testText); | |
hash.get(key).should.equal(testText); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment