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:
@ -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
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user