Archived
1
0

feat: add tests for update.ts (#4835)

* feat: add isAddressInfo helper function

* feat(update): add test for rejection UpdateProvider

* feat: add more tests for UpdateProvider

* fixup! move isAddressInfo, add .address check

* fixup! remove extra writeHead

* fixup! use -1 in redirect logic

* fixup! remove unnecessary String call

* fixup! use /latest for redirect

* fixup! use match group for regex

* fixup!: replace match/split logic
This commit is contained in:
Joe Previte
2022-02-14 13:53:28 -07:00
committed by GitHub
parent 102478bdea
commit c9c5c54cda
2 changed files with 119 additions and 4 deletions

View File

@ -105,3 +105,17 @@ export function idleTimer(message: string, reject: (error: Error) => void, delay
},
}
}
/**
* A helper function which returns a boolean indicating whether
* the given address is AddressInfo and has .address
* and a .port property.
*/
export function isAddressInfo(address: unknown): address is net.AddressInfo {
return (
address !== null &&
typeof address !== "string" &&
(address as net.AddressInfo).port !== undefined &&
(address as net.AddressInfo).address !== undefined
)
}