this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 30e1c9027434f4e1f89e5ca215d3f17b82a6c44b 96 lines 3.0 kB view raw
1var expect = require('chai').expect; 2var Day5 = require('../lib/day5'); 3 4describe('Day5', function() { 5 describe('#hasThreeVowels', function() { 6 it('checks for at least 3 vowels', function() { 7 var niceString = 'axcejill'; 8 var badString = 'aell'; 9 expect(Day5.hasThreeVowels(niceString)).to.equal(true); 10 expect(Day5.hasThreeVowels(badString)).to.equal(false); 11 }); 12 }); 13 14 describe('#hasDoubleLetter', function() { 15 it('has at least one double letter', function() { 16 var niceString = 'asddfmn'; 17 var badString = 'bniosdnf'; 18 expect(Day5.hasDoubleLetter(niceString)).to.equal(true); 19 expect(Day5.hasDoubleLetter(badString)).to.equal(false); 20 }); 21 }); 22 23 describe('#hasBadCombos', function() { 24 it('does not contain "ab" "cd" "pq" or "xy"', function() { 25 var niceString = 'aosidfjo'; 26 var badStrings = [ 27 'oisdjfoiab', 28 'ajossdjfcd', 29 'ajossdjfpq', 30 'ajossdjfxy' 31 ]; 32 33 expect(Day5.hasBadCombos(niceString)).to.equal(false); 34 badStrings.forEach(function(str) { 35 expect(Day5.hasBadCombos(str)).to.equal(true); 36 }); 37 }); 38 }); 39 40 describe('#hasMatchingPairs', function() { 41 it('finds matching pairs of any two letters', function() { 42 var goodStr = 'abasdofijabfji'; 43 var badStr = 'absdoifjojsf'; 44 expect(Day5.hasMatchingPairs(goodStr)).to.equal(true); 45 expect(Day5.hasMatchingPairs(badStr)).to.equal(false); 46 }); 47 48 it('does not count pairs that overlap', function() { 49 var badStr = 'jiosdfaaabxo'; 50 expect(Day5.hasMatchingPairs(badStr)).to.equal(false); 51 }); 52 }); 53 54 describe('#hasRepeatWithBreak', function() { 55 it('finds a repeated letter with one letter in between', function() { 56 var goodStrings = ['xnsabaf', 'fbdaaa', 'dsoinfnsa']; 57 var badStrings = ['fajsdol', 'aosidjf', 'fjdosiap']; 58 goodStrings.forEach(function(str) { 59 expect(Day5.hasRepeatWithBreak(str)).to.equal(true); 60 }) 61 badStrings.forEach(function(str) { 62 expect(Day5.hasRepeatWithBreak(str)).to.equal(false); 63 }) 64 }); 65 }); 66 67 describe('#isStringNice1', function() { 68 it('checks hasThreeVowels, hasDoubleLetter and !hasBadCombos', function() { 69 var goodStrings = ['aeibb', 'oouidd', 'lkajlsdffie']; 70 var badStrings = ['bbbbbbb', 'abbei', 'aeiobx']; 71 72 goodStrings.forEach(function(str) { 73 expect(Day5.isStringNice1(str)).to.equal(true); 74 }); 75 76 badStrings.forEach(function(str) { 77 expect(Day5.isStringNice1(str)).to.equal(false); 78 }); 79 }); 80 }); 81 82 describe('#isStringNice2', function() { 83 it('checks hasRepeatWithBreak and hasMatchingPairs', function() { 84 var goodStrings = ['abfjdsioaba', 'djojdj', 'aspobibsp']; 85 var badStrings = ['asdaf', 'basdgf', 'poiqhbo']; 86 87 goodStrings.forEach(function(str) { 88 expect(Day5.isStringNice2(str)).to.equal(true); 89 }); 90 91 badStrings.forEach(function(str) { 92 expect(Day5.isStringNice2(str)).to.equal(false); 93 }); 94 }); 95 }); 96});