Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ensure our enums are types and values #3146

Merged
merged 3 commits into from
Feb 18, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
GSSAPICanonicalizationValue,
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<GSSAPICanonicalizationValue>(Object.values(GSSAPICanonicalizationValue)[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]);