Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on: [push]
name: Run Tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2

- run: bun install
- run: bun test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This is a Discord Bot build with [Sapphire framework](https://sapphirejs.dev/),

It is a part of the Sunrise project, which aims to create a fully functional osu! private server with all the features that the official server has.

This project also has **automated testing** and **CI/CD** setup with GitHub Actions! ✨

## Installation (with docker) 🐳
1. Clone the repository
Expand Down
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"typescript": "^5"
},
"dependencies": {
"@faker-js/faker": "^9.9.0",
"@sapphire/decorators": "^6.2.0",
"@sapphire/discord.js-utilities": "^7.3.3",
"@sapphire/framework": "^5.3.6",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/osu.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class OsuCommand extends Subcommand {

for (const cmd of subcommandModules) {
;(this as any)[cmd.name] = async (interaction: Subcommand.ChatInputCommandInteraction) => {
return cmd.run.call(this, interaction)
return (cmd.run as any).call(this, interaction)
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions src/commands/tests/meow.command.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect, describe, it, mock, jest, beforeAll, afterAll, beforeEach } from "bun:test"
import { MeowCommand } from "../meow.command"
import { Mocker } from "../../lib/mock/mocker"
import { FakerGenerator } from "../../lib/mock/faker.generator"

describe("Meow Command", () => {
let meowCommand: MeowCommand
let errorHandler: jest.Mock

beforeAll(() => {
Mocker.createSapphireClientInstance()
meowCommand = Mocker.createCommandInstance(MeowCommand)
errorHandler = Mocker.createErrorHandler()
})

afterAll(async () => {
await Mocker.resetSapphireClientInstance()
})

beforeEach(() => Mocker.beforeEachCleanup(errorHandler))

it("should reply with 'meow! 😺' when chatInputRun is called", async () => {
const replyMock = mock()
const interaction = FakerGenerator.generateInteraction({
reply: replyMock,
})

await meowCommand.chatInputRun(interaction)

expect(errorHandler).not.toBeCalled()

expect(replyMock).toHaveBeenCalledWith("meow! 😺")
})
})
Loading