-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from osu-cascades/rc-v2.1.0
- Loading branch information
Showing
14 changed files
with
2,289 additions
and
2,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
node | ||
v13.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Help Command Execute DMs commands with prefix and descriptions it still looks the same 1`] = ` | ||
"I am here to help! Well...mostly just make you chuckle at this point, let's be honest. | ||
Here is a list of the commands that we've got right now: | ||
\`\`\` | ||
!one → I am number one. | ||
!two → Two is not just a number. | ||
!blueFish → Not a red fish. | ||
\`\`\`" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import Help from '../../src/commands/help'; | ||
import Commands from '../../src/library/commands'; | ||
import { message as mockMessage, MockedMessage } from '../mocks/discord'; | ||
|
||
// TODO: These should be in a factory/mock | ||
const oneCommand = { | ||
name: 'one', | ||
description: 'I am number one.', | ||
execute: jest.fn() | ||
}; | ||
|
||
const twoCommand = { | ||
name: 'two', | ||
description: 'Two is not just a number.', | ||
execute: jest.fn() | ||
}; | ||
|
||
const blueFishCommand = { | ||
name: 'blueFish', | ||
description: 'Not a red fish.', | ||
execute: jest.fn() | ||
}; | ||
|
||
const commands = new Commands({ | ||
one: oneCommand, | ||
two: twoCommand, | ||
blueFish: blueFishCommand | ||
}); | ||
|
||
let sendMock: MockedMessage; | ||
let authorSend: MockedMessage; | ||
beforeEach(() => { | ||
sendMock = jest.fn(); | ||
mockMessage.reply = sendMock; | ||
authorSend = jest.fn(); | ||
// @ts-ignore | ||
mockMessage.author = { | ||
send: authorSend | ||
}; | ||
}); | ||
|
||
describe('Help Command', () => { | ||
describe('Execute', () => { | ||
beforeEach(() => { | ||
Help.execute([], mockMessage, { commands }); | ||
}); | ||
|
||
test('Lets you know to check your DMs', () => { | ||
expect(sendMock).lastCalledWith('sliding into your DMs...'); | ||
}); | ||
|
||
describe('DMs commands with prefix and descriptions', () => { | ||
let message: string; | ||
beforeEach(() => { | ||
message = authorSend.mock.calls[0][0]; | ||
}); | ||
|
||
test('Snarky', () => { | ||
const snark = "I am here to help! Well...mostly just make you chuckle " + | ||
"at this point, let's be honest."; | ||
expect(message).toContain(snark); | ||
}); | ||
|
||
test('Command pretext header', () => { | ||
const pretext = "Here is a list of the commands that we've got right now:"; | ||
expect(message).toContain(pretext); | ||
}); | ||
|
||
test('Code block start', () => { | ||
expect(message).toContain('```\n'); | ||
}); | ||
|
||
test('Code block end', () => { | ||
const lines = message.split('\n'); | ||
const lastLine = lines[lines.length - 1]; | ||
expect(lastLine).toEqual('```'); | ||
}); | ||
|
||
test('it still looks the same', () => { | ||
expect(message).toMatchSnapshot(); | ||
}); | ||
|
||
describe('Commands', () => { | ||
test('one command', () => { | ||
expect(message).toContain('!one'); | ||
}); | ||
|
||
test('one description', () => { | ||
expect(message).toContain(oneCommand.description); | ||
}); | ||
|
||
test('two command', () => { | ||
expect(message).toContain('!two'); | ||
}); | ||
|
||
test('two description', () => { | ||
expect(message).toContain(twoCommand.description); | ||
}); | ||
|
||
test('blueFish command', () => { | ||
expect(message).toContain('!blueFish'); | ||
}); | ||
|
||
test('BlueFish description', () => { | ||
expect(message).toContain(blueFishCommand.description); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
import { ICommandClasses } from '../../src/library/commandLoader'; | ||
import Commands from '../../src/library/commands'; | ||
import ICommand from '../../src/library/iCommand'; | ||
|
||
// TODO: I feel like this class is too basic to test, | ||
// and ultimately a wrapper for other classes that have been tested | ||
// Might just remove it some day | ||
describe('Commands', () => { | ||
const commands = new Commands(); | ||
test('Has a command', () => { | ||
expect(Object.keys(commands.all).length).toBeGreaterThan(0); | ||
expect(commands.names.length).toBeGreaterThan(0); | ||
let mockHelloCommand: ICommand; | ||
let mockYetAnotherCommand: ICommand; | ||
let mockCommands: ICommandClasses; | ||
let commands: Commands; | ||
|
||
beforeEach(() => { | ||
// TODO: these should probably go into a factory/mock | ||
mockHelloCommand = { | ||
name: 'Hello', | ||
description: 'Hello World', | ||
execute: jest.fn() | ||
}; | ||
mockYetAnotherCommand = { | ||
name: 'YAC', | ||
description: 'Yet Another Command!', | ||
execute: jest.fn() | ||
}; | ||
mockCommands = { | ||
hello: mockHelloCommand, | ||
yac: mockYetAnotherCommand | ||
}; | ||
commands = new Commands(mockCommands); | ||
}); | ||
|
||
test('.names returns command names', () => { | ||
const commandNames = ['hello', 'yac']; | ||
expect(commands.names).toEqual(commandNames); | ||
}); | ||
|
||
test('Can fetch a command', () => { | ||
const first = commands.names[0]; | ||
expect(commands.get(first)).not.toBeUndefined(); | ||
const helloCommand = commands.get('hello'); | ||
expect(helloCommand).toBe(mockHelloCommand); | ||
}); | ||
|
||
test('Finds the longest name', () => { | ||
expect(commands.longestNameLength()).toEqual(5); | ||
}); | ||
}); |
Oops, something went wrong.