Skip to main content

@rbxts/expect > Assertion > enum

Assertion.enum() method

Asserts that the value is an enum of type R.

Signature:

enum<R>(enumType: R & Record<number, string>): Assertion<EnumValue<R>>;

Parameters

Parameter

Type

Description

enumType

R & Record<number, string>

A TS defined enum or an equivalent record in lua.

Returns:

Assertion<EnumValue<R>>

Remarks

This is not for ROBLOX specific enums, but for user defined enums.

Example

enum Sport {
Basketball,
Football,
Soccer
}

expect(Sport.Basketball).to.be.the.enum(Sport);
expect("Basketball").to.be.the.enum(Sport);
expect(0).to.be.the.enum(Sport);