Skip to content

Commit

Permalink
Update workflows & Fix test for leaving DM channel
Browse files Browse the repository at this point in the history
  • Loading branch information
TTTaevas committed Oct 14, 2024
1 parent 2c6a88e commit 43c8bb1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
name: Publish on NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'

- run: yarn
- run: yarn publish
- run: npm
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Node.js Vitest CI
on:
push:
branches:
- "**"
pull_request:
branches:
- "**"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run test
env:
ID: ${{ secrets.OSU_ID }}
SECRET: ${{ secrets.OSU_SECRET }}
23 changes: 13 additions & 10 deletions lib/tests/authenticateduser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,23 @@ describe("Chat stuff", () => {
})
})

let dm_channel: osu.Chat.Channel
test("createChatPrivateChannel", async () => {
const channel = await api.createChatPrivateChannel(3)
expectTypeOf(channel).toEqualTypeOf<Awaited<ReturnType<typeof api.createChatPrivateChannel>>>()
dm_channel = await api.createChatPrivateChannel(3)
expectTypeOf(dm_channel).toEqualTypeOf<Awaited<ReturnType<typeof api.createChatPrivateChannel>>>()
})

test("sendChatPrivateMessage", async () => {
const event = await api.sendChatPrivateMessage(3, "hello")
expect(event.message).toHaveProperty("content", "hello")
expectTypeOf(event).toEqualTypeOf<Awaited<ReturnType<typeof api.sendChatPrivateMessage>>>()
})
describe("Interact with a private channel", () => {
test("sendChatPrivateMessage", async () => {
const event = await api.sendChatPrivateMessage(3, "hello") // sendChatPrivateMessage uses the USER's id
expect(event.message).toHaveProperty("content", "hello")
expectTypeOf(event).toEqualTypeOf<Awaited<ReturnType<typeof api.sendChatPrivateMessage>>>()
})

test("leaveChatChannel", async () => {
const response = await api.leaveChatChannel(3)
expectTypeOf(response).toEqualTypeOf<Awaited<ReturnType<typeof api.leaveChatChannel>>>()
test("leaveChatChannel", async () => {
const response = await api.leaveChatChannel(dm_channel) // leaveChatChannel uses the CHANNEL's id
expectTypeOf(response).toEqualTypeOf<Awaited<ReturnType<typeof api.leaveChatChannel>>>()
})
})

test("keepChatAlive", async () => {
Expand Down

0 comments on commit 43c8bb1

Please sign in to comment.