File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 2626( function ( exports ) {
2727 'use strict' ;
2828
29- exports . HashTable = function ( ) {
29+ exports . HashTable = function HashTable ( ) {
3030 this . elements = [ ] ;
3131 } ;
3232
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments