From 154a287f35363d70eb518e142628be1f0bb78215 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 18 Feb 2022 11:53:07 -0500 Subject: [PATCH] fix: lint! --- test/types/enum.test-d.ts | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/test/types/enum.test-d.ts b/test/types/enum.test-d.ts index 39fc2f9f0d..225282f618 100644 --- a/test/types/enum.test-d.ts +++ b/test/types/enum.test-d.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { expectType } from 'tsd'; +import { expectAssignable, expectType } from 'tsd'; import { AuthMechanism, @@ -21,23 +21,27 @@ import { TopologyType } from '../../src/index'; +const num: number = Math.random(); + // In our index.ts we clump CURSOR_FLAGS with the enums but its an array -expectType(CURSOR_FLAGS[0]); +expectType(CURSOR_FLAGS[num]); + +// Explain is kept as type string so we can automatically allow any new level to be passed through +expectAssignable(Object.values(ExplainVerbosity)[num]); // Note both the Enum name and a property on the enum are the same type -// Object.values(x)[0] gets a union of the all the value types -expectType(Object.values(AuthMechanism)[0]); -expectType(Object.values(AutoEncryptionLoggerLevel)[0]); -expectType(Object.values(BatchType)[0]); -expectType(Object.values(BSONType)[0]); -expectType(Object.values(Compressor)[0]); -expectType(Object.values(ExplainVerbosity)[0]); -expectType(Object.values(GSSAPICanonicalizationValue)[0]); -expectType(Object.values(LoggerLevel)[0]); -expectType(Object.values(ProfilingLevel)[0]); -expectType(Object.values(ReadConcernLevel)[0]); -expectType(Object.values(ReadPreferenceMode)[0]); -expectType(Object.values(ReturnDocument)[0]); -expectType(Object.values(ServerApiVersion)[0]); -expectType(Object.values(ServerType)[0]); -expectType(Object.values(TopologyType)[0]); +// Object.values(x)[num] gets a union of the all the value types +expectType(Object.values(AuthMechanism)[num]); +expectType(Object.values(AutoEncryptionLoggerLevel)[num]); +expectType(Object.values(BatchType)[num]); +expectType(Object.values(BSONType)[num]); +expectType(Object.values(Compressor)[num]); +expectType(Object.values(GSSAPICanonicalizationValue)[num]); +expectType(Object.values(LoggerLevel)[num]); +expectType(Object.values(ProfilingLevel)[num]); +expectType(Object.values(ReadConcernLevel)[num]); +expectType(Object.values(ReadPreferenceMode)[num]); +expectType(Object.values(ReturnDocument)[num]); +expectType(Object.values(ServerApiVersion)[num]); +expectType(Object.values(ServerType)[num]); +expectType(Object.values(TopologyType)[num]);