|
| 1 | +const expect = require('chai').expect; |
| 2 | +const Dictionary = require('../../examples/datastructures/dictionary'); |
| 3 | + |
| 4 | +describe('=> DICTIONARY', function() { |
| 5 | + let numbers; |
| 6 | + before(function () { |
| 7 | + numbers = new Dictionary(); |
| 8 | + }); |
| 9 | + |
| 10 | + it('should create an Empty Dictionary', function(done) { |
| 11 | + expect(numbers.dataStore).to.deep.equal([]); |
| 12 | + done(); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should set a <key,value> pair in the Dictionary', function(done) { |
| 16 | + numbers.set("Champu", 3370123459); |
| 17 | + numbers.set("Zhampak", 123991283); |
| 18 | + numbers.set("Raju", 7118780921); |
| 19 | + expect(numbers.dataStore["Champu"]).to.equal(3370123459); |
| 20 | + expect(numbers.dataStore["Zhampak"]).to.equal(123991283); |
| 21 | + expect(numbers.dataStore["Raju"]).to.equal(7118780921); |
| 22 | + done(); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should get a value from the Dictionary', function(done) { |
| 26 | + expect(numbers.get("Champu")).to.equal(3370123459); |
| 27 | + expect(numbers.get("Zhampak")).to.equal(123991283); |
| 28 | + expect(numbers.get("Raju")).to.equal(7118780921); |
| 29 | + done(); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should show all values from the Dictionary', function(done) { |
| 33 | + expect(numbers.showAll()).to.equal("Champu -> 3370123459\nZhampak -> 123991283\nRaju -> 7118780921\n"); |
| 34 | + done(); |
| 35 | + }); |
| 36 | + |
| 37 | + it('should remove a value from the Dictionary', function(done) { |
| 38 | + numbers.remove("Raju"); |
| 39 | + expect(numbers.get("Raju")).to.equal(undefined); |
| 40 | + done(); |
| 41 | + }); |
| 42 | + |
| 43 | + describe('=> clear', function() { |
| 44 | + it('should clear the Dictionary', function(done) { |
| 45 | + numbers.clear(); |
| 46 | + expect(numbers.dataStore).to.deep.equal([]); |
| 47 | + done(); |
| 48 | + }); |
| 49 | + }); |
| 50 | + |
| 51 | +}); |
0 commit comments