Code coverage report for spec/algo/1-strings/compress.spec.js

Statements: 100% (17 / 17)      Branches: 100% (0 / 0)      Functions: 100% (5 / 5)      Lines: 100% (17 / 17)      Ignored: none     

All files » spec/algo/1-strings/ » compress.spec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321   1   1 1   1 1   1 1   1   1 1     1 1     1 1     1 1      
var compress = require("../../../lib/algorithms/1-strings/compress.js");
 
describe('When using compress() on a string', function () {
 
	var preCompress1 = "aaabbbccccddeeeee";
	var postCompress1 = "a3b3c4d2e5";
 
	var preCompress2 = "aaabbbccccddeeeeez";
	var postCompress2 = "a3b3c4d2e5z1";
 
	var preCompress3 = "zaaabbbccccddeeeee";
	var postCompress3 = "z1a3b3c4d2e5";
 
	var uncompressable = "asdfghjklzxcvbnm"
 
	it('if the string is compressable, a new compressed string will be returned.', function () {
		expect(compress(preCompress1)).toEqual(postCompress1);
	});
 
	it('if the string is compressable, and has a different character at the end, a new compressed string will be returned.', function () {
		expect(compress(preCompress2)).toEqual(postCompress2);
	});
 
	it('if the string is compressable, and has a different character at the beginning, a new compressed string will be returned.', function () {
		expect(compress(preCompress3)).toEqual(postCompress3);
	});
 
	it('if a string is not compressable, the same string will be returned', function () {
		expect(compress(uncompressable)).toEqual(uncompressable);
	});
 
});