Files
discord.js/packages/builders/__tests__/util.test.ts
2022-07-17 21:20:26 +02:00

43 lines
1.0 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import {
isJSONEncodable,
isEquatable,
ActionRowBuilder,
enableValidators,
disableValidators,
isValidationEnabled,
} from '../src/index';
describe('isEquatable', () => {
test('returns true if the object is equatable', () => {
expect(isEquatable({ equals: () => true })).toBeTruthy();
});
test('returns false if the object is not equatable', () => {
expect(isEquatable({})).toBeFalsy();
});
});
describe('isJSONEncodable', () => {
test('returns true if the object is JSON encodable', () => {
expect(isJSONEncodable({ toJSON: () => ({}) })).toBeTruthy();
expect(isJSONEncodable(new ActionRowBuilder())).toBeTruthy();
});
test('returns false if the object is not JSON encodable', () => {
expect(isJSONEncodable({})).toBeFalsy();
});
});
describe('validation', () => {
test('enables validation', () => {
enableValidators();
expect(isValidationEnabled()).toBeTruthy();
});
test('disables validation', () => {
disableValidators();
expect(isValidationEnabled()).toBeFalsy();
});
});