11import { describe , it , expect } from "bun:test" ;
22import {
33 day_2_part_1 ,
4+ day_2_part_2 ,
45 isReportSafe ,
56 transformInputIntoArrays ,
7+ removeFirstNonSequential ,
68} from "./day-2-red-nosed-reports" ;
79
810const fileTest = Bun . file ( "./src/day-2-red-nosed-reports.input.test.txt" ) ;
@@ -64,6 +66,44 @@ describe("transformInputIntoArrays", () => {
6466 } ) ;
6567} ) ;
6668
69+ describe ( "removeFirstNonSequential" , ( ) => {
70+ it ( "return [7, 6, 4, 2, 1] for [7, 6, 4, 2, 1]" , ( ) => {
71+ const result = removeFirstNonSequential ( [ 7 , 6 , 4 , 2 , 1 ] ) ;
72+ const expected = [ 7 , 6 , 4 , 2 , 1 ] ;
73+ expect ( result ) . toEqual ( expected ) ;
74+ } ) ;
75+ it ( "return [1, 2, 7, 8, 9] for [1, 2, 7, 8, 9]" , ( ) => {
76+ const result = removeFirstNonSequential ( [ 1 , 2 , 7 , 8 , 9 ] ) ;
77+ const expected = [ 1 , 2 , 7 , 8 , 9 ] ;
78+ expect ( result ) . toEqual ( expected ) ;
79+ } ) ;
80+ it ( "return [9, 7, 6, 2, 1] for [9, 7, 6, 2, 1]" , ( ) => {
81+ const result = removeFirstNonSequential ( [ 9 , 7 , 6 , 2 , 1 ] ) ;
82+ const expected = [ 9 , 7 , 6 , 2 , 1 ] ;
83+ expect ( result ) . toEqual ( expected ) ;
84+ } ) ;
85+ it ( "return [1, 2, 4, 5] for [1, 3, 2, 4, 5]" , ( ) => {
86+ const result = removeFirstNonSequential ( [ 1 , 3 , 2 , 4 , 5 ] ) ;
87+ const expected = [ 1 , 2 , 4 , 5 ] ;
88+ expect ( result ) . toEqual ( expected ) ;
89+ } ) ;
90+ it ( "return [8, 6, 4, 1] for [8, 6, 4, 4, 1]" , ( ) => {
91+ const result = removeFirstNonSequential ( [ 8 , 6 , 4 , 4 , 1 ] ) ;
92+ const expected = [ 8 , 6 , 4 , 1 ] ;
93+ expect ( result ) . toEqual ( expected ) ;
94+ } ) ;
95+ it ( "return [1, 3, 6, 7, 9] for [1, 3, 6, 7, 9]" , ( ) => {
96+ const result = removeFirstNonSequential ( [ 1 , 3 , 6 , 7 , 9 ] ) ;
97+ const expected = [ 1 , 3 , 6 , 7 , 9 ] ;
98+ expect ( result ) . toEqual ( expected ) ;
99+ } ) ;
100+ it . skip ( "return [ 2, 4, 6, 9, 10] for [ 2, 4, 6, 9, 10, 9 ]" , ( ) => {
101+ const result = removeFirstNonSequential ( [ 2 , 4 , 6 , 9 , 10 , 9 ] ) ;
102+ const expected = [ 2 , 4 , 6 , 9 , 10 ] ;
103+ expect ( result ) . toEqual ( expected ) ;
104+ } ) ;
105+ } ) ;
106+
67107describe ( "Day 2: Red-Nosed Reports" , ( ) => {
68108 describe ( "part 1" , ( ) => {
69109 it ( "should return the correct amount of report from the test file" , ( ) => {
@@ -79,4 +119,18 @@ describe("Day 2: Red-Nosed Reports", () => {
79119 expect ( typeof contentTest ) . toBe ( "string" ) ;
80120 } ) ;
81121 } ) ;
122+ describe ( "part 2" , ( ) => {
123+ it ( "should return the correct amount of report from the test file" , ( ) => {
124+ const result = day_2_part_2 ( contentTest ) ;
125+ const expected = 4 ;
126+ expect ( result ) . toBe ( expected ) ;
127+ expect ( typeof contentTest ) . toBe ( "string" ) ;
128+ } ) ;
129+ it . skip ( "should return the correct amount of report from the file" , ( ) => {
130+ const result = day_2_part_2 ( content ) ;
131+ const expected = 307 ;
132+ expect ( result ) . toBe ( expected ) ;
133+ expect ( typeof contentTest ) . toBe ( "string" ) ;
134+ } ) ;
135+ } ) ;
82136} ) ;
0 commit comments