|
| 1 | +"use strict"; |
| 2 | +const assert = require("assert"), |
| 3 | + Record = require("../src/record"); |
| 4 | + |
| 5 | +describe("Record Test", () => { |
| 6 | + describe('getString()', () => { |
| 7 | + const recordUnderTest = new Record([ |
| 8 | + "key", |
| 9 | + "keyForEmptyString", |
| 10 | + "keyForZero", |
| 11 | + "keyForTwelve", |
| 12 | + "keyForNullValue" |
| 13 | + ], [ |
| 14 | + "valueForKey", |
| 15 | + "", |
| 16 | + 0, |
| 17 | + 12, |
| 18 | + null |
| 19 | + ]); |
| 20 | + |
| 21 | + context('key is not given', () => { |
| 22 | + it('returns null', () => { |
| 23 | + assert.equal(recordUnderTest.getString(), null); |
| 24 | + }); |
| 25 | + }); |
| 26 | + context('key is undefined', () => { |
| 27 | + it('returns null', () => { |
| 28 | + assert.equal(recordUnderTest.getString(undefined), null); |
| 29 | + }); |
| 30 | + }); |
| 31 | + context('value is empty string', () => { |
| 32 | + it('returns empty string', () => { |
| 33 | + assert.equal(recordUnderTest.getString('keyForEmptyString'), ''); |
| 34 | + }); |
| 35 | + }); |
| 36 | + context('value is zero (0)', () => { |
| 37 | + it('returns zero (0) as string', () => { |
| 38 | + assert.equal(recordUnderTest.getString('keyForZero'), '0'); |
| 39 | + }); |
| 40 | + }); |
| 41 | + context('value is non-zero integer', () => { |
| 42 | + it('returns non-zero integer as string', () => { |
| 43 | + assert.equal(recordUnderTest.getString('keyForTwelve'), '12'); |
| 44 | + }); |
| 45 | + }); |
| 46 | + context('value is string', () => { |
| 47 | + it('returns value', () => { |
| 48 | + assert.equal(recordUnderTest.getString('key'), 'valueForKey'); |
| 49 | + }); |
| 50 | + }); |
| 51 | + context('value is null', () => { |
| 52 | + it('returns null', () => { |
| 53 | + assert.equal(recordUnderTest.getString('keyForNullValue'), null); |
| 54 | + }); |
| 55 | + }); |
| 56 | + }); |
| 57 | +}); |
0 commit comments