11import { afterEach , beforeEach , describe , expect , mock , test } from "bun:test" ;
2- import { createBetterstackProvider } from "./provider" ;
32import {
43 MOCK_INCIDENTS ,
54 MOCK_MONITORS ,
65 MOCK_MONITOR_GROUPS ,
76 MOCK_STATUS_PAGES ,
87 MOCK_STATUS_PAGE_SECTIONS ,
98} from "./fixtures" ;
9+ import { createBetterstackProvider } from "./provider" ;
1010
1111const originalFetch = globalThis . fetch ;
1212
@@ -112,8 +112,8 @@ describe("BetterstackProvider", () => {
112112
113113 const monitorsPhase = summary . phases . find ( ( p ) => p . phase === "monitors" ) ;
114114 expect ( monitorsPhase ) . toBeDefined ( ) ;
115- expect ( monitorsPhase ! . resources ) . toHaveLength ( 3 ) ;
116- expect ( monitorsPhase ! . resources [ 0 ] . name ) . toBe ( "API Health Check" ) ;
115+ expect ( monitorsPhase ? .resources ) . toHaveLength ( 3 ) ;
116+ expect ( monitorsPhase ? .resources [ 0 ] . name ) . toBe ( "API Health Check" ) ;
117117 } ) ;
118118
119119 test ( "page phase maps status page correctly" , async ( ) => {
@@ -125,8 +125,8 @@ describe("BetterstackProvider", () => {
125125
126126 const pagePhase = summary . phases . find ( ( p ) => p . phase === "page" ) ;
127127 expect ( pagePhase ) . toBeDefined ( ) ;
128- expect ( pagePhase ! . resources ) . toHaveLength ( 1 ) ;
129- expect ( pagePhase ! . resources [ 0 ] . name ) . toBe ( "Acme Corp" ) ;
128+ expect ( pagePhase ? .resources ) . toHaveLength ( 1 ) ;
129+ expect ( pagePhase ? .resources [ 0 ] . name ) . toBe ( "Acme Corp" ) ;
130130 } ) ;
131131
132132 test ( "incidents phase maps all incidents" , async ( ) => {
@@ -138,7 +138,7 @@ describe("BetterstackProvider", () => {
138138
139139 const incidentsPhase = summary . phases . find ( ( p ) => p . phase === "incidents" ) ;
140140 expect ( incidentsPhase ) . toBeDefined ( ) ;
141- expect ( incidentsPhase ! . resources ) . toHaveLength ( 3 ) ;
141+ expect ( incidentsPhase ? .resources ) . toHaveLength ( 3 ) ;
142142 } ) ;
143143
144144 test ( "filters by betterstackStatusPageId" , async ( ) => {
@@ -155,7 +155,7 @@ describe("BetterstackProvider", () => {
155155
156156 const monitorsPhase = summary . phases . find ( ( p ) => p . phase === "monitors" ) ;
157157 expect ( monitorsPhase ) . toBeDefined ( ) ;
158- expect ( monitorsPhase ! . resources ) . toHaveLength ( 3 ) ;
158+ expect ( monitorsPhase ? .resources ) . toHaveLength ( 3 ) ;
159159 } ) ;
160160
161161 test ( "monitor resources include sourceMonitorGroupId" , async ( ) => {
@@ -166,13 +166,13 @@ describe("BetterstackProvider", () => {
166166 } ) ;
167167
168168 const monitorsPhase = summary . phases . find ( ( p ) => p . phase === "monitors" ) ;
169- const firstMonitor = monitorsPhase ! . resources [ 0 ] . data as Record <
169+ const firstMonitor = monitorsPhase ? .resources [ 0 ] . data as Record <
170170 string ,
171171 unknown
172172 > ;
173173 expect ( firstMonitor . sourceMonitorGroupId ) . toBe ( "bs_group_001" ) ;
174174
175- const thirdMonitor = monitorsPhase ! . resources [ 2 ] . data as Record <
175+ const thirdMonitor = monitorsPhase ? .resources [ 2 ] . data as Record <
176176 string ,
177177 unknown
178178 > ;
0 commit comments