Skip to content

Commit 2217e28

Browse files
committed
1 parent 793086f commit 2217e28

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/data-structures/hash-table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(function (exports) {
2727
'use strict';
2828

29-
exports.HashTable = function () {
29+
exports.HashTable = function HashTable() {
3030
this.elements = [];
3131
};
3232

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var HashTable = require('../../src/data-structures/hash-table').HashTable;
2+
3+
describe('HashTable', function () {
4+
'use strict';
5+
it('should be defined as constructor function', function () {
6+
expect(typeof HashTable).toBe('function');
7+
var hash = new HashTable();
8+
expect(hash instanceof HashTable).toBeTruthy();
9+
expect(hash.constructor.name).toBe('HashTable');
10+
});
11+
12+
describe('methods', function () {
13+
it('should define a put and get methods', function () {
14+
var hash = new HashTable();
15+
expect(typeof hash.put).toBe('function');
16+
expect(typeof hash.get).toBe('function');
17+
hash.put('key', 'value');
18+
expect(hash.get('key')).toBe('value');
19+
hash.put('key', 'foo');
20+
expect(hash.get('key')).toBe('foo');
21+
hash.put('bar', 'baz');
22+
expect(hash.get('bar')).toBe('baz');
23+
});
24+
25+
it('should define a remove method', function () {
26+
});
27+
});
28+
});

0 commit comments

Comments
 (0)