11/* eslint-env mocha */
22const { expect } = require ( 'chai' )
33const { checksumSet, checksumUnSanitizedSet, checksumLine, sanitizeLine } = require ( './checksum' )
4+ const fs = require ( 'fs' )
5+ const path = require ( 'path' )
6+ const filePath = path . join ( __dirname , 'input.txt' )
7+ const { inputToArray } = require ( '../../2018/inputParser' )
48
59describe ( '--- Day 1: Trebuchet?! ---' , ( ) => {
610 describe ( 'Part 1' , ( ) => {
@@ -45,7 +49,7 @@ describe('--- Day 1: Trebuchet?! ---', () => {
4549 expect ( sanitizeLine ( 'eightwothree' ) ) . to . equal ( '8wo3' )
4650 } )
4751 } )
48- describe ( 'checksumUnsanitizedSet ' , ( ) => {
52+ describe ( 'checksumUnSanitizedSet ' , ( ) => {
4953 it ( 'calculates the checksum for a set of lines by summing the checksum of each sanitized line' , ( ) => {
5054 const set = [
5155 'two1nine' ,
@@ -59,5 +63,18 @@ describe('--- Day 1: Trebuchet?! ---', () => {
5963 expect ( checksumUnSanitizedSet ( set ) ) . to . equal ( 281 )
6064 } )
6165 } )
66+ describe ( 'integeration' , ( ) => {
67+ it ( '53853 is too low for part 2' , ( done ) => {
68+ let data
69+ fs . readFile ( filePath , { encoding : 'utf8' } , ( err , initData ) => {
70+ if ( err ) throw err
71+ initData = inputToArray ( initData . trim ( ) )
72+ // Deep copy to ensure we aren't mutating the original data
73+ data = JSON . parse ( JSON . stringify ( initData ) )
74+ expect ( checksumUnSanitizedSet ( data ) ) . to . be . greaterThan ( 53853 )
75+ done ( )
76+ } )
77+ } )
78+ } )
6279 } )
6380} )
0 commit comments