Skip to content

Commit

Permalink
test: ensure our enums are types and values
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Feb 15, 2022
1 parent b192493 commit ac220e8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/types/enum.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { expectType } from 'tsd';

import {
AuthMechanism,
AutoEncryptionLoggerLevel,
BatchType,
BSONType,
Compressor,
CURSOR_FLAGS,
CursorFlag,
ExplainVerbosity,
// GSSAPICanonicalizationValues,
LoggerLevel,
ProfilingLevel,
ReadConcernLevel,
ReadPreferenceMode,
ReturnDocument,
ServerApiVersion,
ServerType,
TopologyType
} from '../../src/index';

// In our index.ts we clump CURSOR_FLAGS with the enums but its an array
expectType<CursorFlag>(CURSOR_FLAGS[0]);

// 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<AuthMechanism>(Object.values(AuthMechanism)[0]);
expectType<AutoEncryptionLoggerLevel>(Object.values(AutoEncryptionLoggerLevel)[0]);
expectType<BatchType>(Object.values(BatchType)[0]);
expectType<BSONType>(Object.values(BSONType)[0]);
expectType<Compressor>(Object.values(Compressor)[0]);
expectType<ExplainVerbosity>(Object.values(ExplainVerbosity)[0]);
// expectType<GSSAPICanonicalizationValues>(Object.values(GSSAPICanonicalizationValues)[0]);
expectType<LoggerLevel>(Object.values(LoggerLevel)[0]);
expectType<ProfilingLevel>(Object.values(ProfilingLevel)[0]);
expectType<ReadConcernLevel>(Object.values(ReadConcernLevel)[0]);
expectType<ReadPreferenceMode>(Object.values(ReadPreferenceMode)[0]);
expectType<ReturnDocument>(Object.values(ReturnDocument)[0]);
expectType<ServerApiVersion>(Object.values(ServerApiVersion)[0]);
expectType<ServerType>(Object.values(ServerType)[0]);
expectType<TopologyType>(Object.values(TopologyType)[0]);

0 comments on commit ac220e8

Please sign in to comment.