|
| 1 | +/* eslint-disable @typescript-eslint/no-unused-vars */ |
| 2 | +import { expectAssignable, expectType } from 'tsd'; |
| 3 | + |
| 4 | +import { |
| 5 | + AuthMechanism, |
| 6 | + AutoEncryptionLoggerLevel, |
| 7 | + BatchType, |
| 8 | + BSONType, |
| 9 | + Compressor, |
| 10 | + CURSOR_FLAGS, |
| 11 | + CursorFlag, |
| 12 | + ExplainVerbosity, |
| 13 | + GSSAPICanonicalizationValue, |
| 14 | + LoggerLevel, |
| 15 | + ProfilingLevel, |
| 16 | + ReadConcernLevel, |
| 17 | + ReadPreferenceMode, |
| 18 | + ReturnDocument, |
| 19 | + ServerApiVersion, |
| 20 | + ServerType, |
| 21 | + TopologyType |
| 22 | +} from '../../src/index'; |
| 23 | + |
| 24 | +const num: number = Math.random(); |
| 25 | + |
| 26 | +// In our index.ts we clump CURSOR_FLAGS with the enums but its an array |
| 27 | +expectType<CursorFlag>(CURSOR_FLAGS[num]); |
| 28 | + |
| 29 | +// Explain is kept as type string so we can automatically allow any new level to be passed through |
| 30 | +expectAssignable<string>(Object.values(ExplainVerbosity)[num]); |
| 31 | + |
| 32 | +// Note both the Enum name and a property on the enum are the same type |
| 33 | +// Object.values(x)[num] gets a union of the all the value types |
| 34 | +expectType<AuthMechanism>(Object.values(AuthMechanism)[num]); |
| 35 | +expectType<AutoEncryptionLoggerLevel>(Object.values(AutoEncryptionLoggerLevel)[num]); |
| 36 | +expectType<BatchType>(Object.values(BatchType)[num]); |
| 37 | +expectType<BSONType>(Object.values(BSONType)[num]); |
| 38 | +expectType<Compressor>(Object.values(Compressor)[num]); |
| 39 | +expectType<GSSAPICanonicalizationValue>(Object.values(GSSAPICanonicalizationValue)[num]); |
| 40 | +expectType<LoggerLevel>(Object.values(LoggerLevel)[num]); |
| 41 | +expectType<ProfilingLevel>(Object.values(ProfilingLevel)[num]); |
| 42 | +expectType<ReadConcernLevel>(Object.values(ReadConcernLevel)[num]); |
| 43 | +expectType<ReadPreferenceMode>(Object.values(ReadPreferenceMode)[num]); |
| 44 | +expectType<ReturnDocument>(Object.values(ReturnDocument)[num]); |
| 45 | +expectType<ServerApiVersion>(Object.values(ServerApiVersion)[num]); |
| 46 | +expectType<ServerType>(Object.values(ServerType)[num]); |
| 47 | +expectType<TopologyType>(Object.values(TopologyType)[num]); |
0 commit comments