mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 16:30:08 +00:00
I prefer semicolors, they also help avoiding certain pitfalls in JavaScript/TypeScript, such as the following code sample: ```js const xyz = "test" (something.else as string) = "another" ``` This results in a TypeError: "test" is not a function, this is because js thinks we are trying to call the string "test" as a function. To fix this it requires a `;` somewhere before the `(`, such as `;(something ... ` which in my opinion is ugly and less clean overall.
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { use as chaiUse, expect } from 'chai';
|
|
import chaiAsPromised from 'chai-as-promised';
|
|
import { describe, it } from 'mocha';
|
|
import { rest } from './utils.js';
|
|
|
|
chaiUse(chaiAsPromised);
|
|
|
|
describe('Get a user from the api', () => {
|
|
it('With a valid user id', async () => {
|
|
const user = await rest.getUser('130136895395987456');
|
|
|
|
describe('User has correct shape and form', () => {
|
|
it('Has correct id', () => {
|
|
expect(user.id).to.be.equal('130136895395987456');
|
|
});
|
|
|
|
it('Has a valid username', () => {
|
|
expect(user.username.length).to.be.greaterThanOrEqual(1);
|
|
});
|
|
|
|
it('Has a valid discriminator', () => {
|
|
expect(user.discriminator.length).to.be.oneOf([1, 4]);
|
|
});
|
|
|
|
it('Has been camelized', () => {
|
|
const keys = Object.keys(user);
|
|
|
|
expect(keys.includes('public_flags')).to.be.false;
|
|
expect(keys.includes('publicFlags')).to.be.true;
|
|
});
|
|
});
|
|
});
|
|
|
|
it('With an invalid user id', async () => {
|
|
await expect(rest.getUser('123')).eventually.rejected;
|
|
});
|
|
});
|