createMockTheme
function in meocord/testing Since 4.1.0
createMockTheme(...overrides: MockThemeArgs): DeepReadonly<MeoCordTheme>Makes a whole theme for a test: MeoCord's defaults with overrides merged over them, frozen.
It is the theme as useTheme() reads it: pass it where code takes a theme, run code in it with withTheme,
or compare against it. createMockTheme() is the theme a testing module with no theme reads.
Parameters
| Name | Type | Description |
|---|---|---|
...overrides | MockThemeArgs | The roles to change, in any group, checked as |
Returns
DeepReadonly<MeoCordTheme>Throws
Error naming each token that is not valid.
Examples
import { expect } from 'vitest'
const refunded = () => new EmbedBuilder().setColor(useTheme().colors.danger).setTitle('Refunded')
const embed = withTheme(createMockTheme({ colors: { danger: '#E3606D' } }), refunded)
expect(embed.data.color).toBe(0xe3606d)