1
1
/* eslint-env mocha */
2
2
const { expect } = require ( 'chai' )
3
3
const { 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' )
4
8
5
9
describe ( '--- Day 1: Trebuchet?! ---' , ( ) => {
6
10
describe ( 'Part 1' , ( ) => {
@@ -45,7 +49,7 @@ describe('--- Day 1: Trebuchet?! ---', () => {
45
49
expect ( sanitizeLine ( 'eightwothree' ) ) . to . equal ( '8wo3' )
46
50
} )
47
51
} )
48
- describe ( 'checksumUnsanitizedSet ' , ( ) => {
52
+ describe ( 'checksumUnSanitizedSet ' , ( ) => {
49
53
it ( 'calculates the checksum for a set of lines by summing the checksum of each sanitized line' , ( ) => {
50
54
const set = [
51
55
'two1nine' ,
@@ -59,5 +63,18 @@ describe('--- Day 1: Trebuchet?! ---', () => {
59
63
expect ( checksumUnSanitizedSet ( set ) ) . to . equal ( 281 )
60
64
} )
61
65
} )
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
+ } )
62
79
} )
63
80
} )
0 commit comments