Skip to content

Commit

Permalink
test: add test framework and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Sep 12, 2023
1 parent c45610c commit f7fc00d
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
extends: "@hamster-bot/eslint-config/typescript"
extends: '@hamster-bot/eslint-config/typescript'

rules:
# TypeScript would do this check so we don't need this.
import/no-unresolved: off

ignorePatterns:
- node_modules
- lib
- dist
- coverage
- docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
lint:
strategy:
matrix:
version: [14, 16, 18]
version: [14, 16, 18, 20]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
lint:
strategy:
matrix:
version: [14, 16, 18, 20]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}

- name: Install dependencies
run: yarn install

- name: Build
run: yarn run build

- name: Test
run: yarn run test
18 changes: 18 additions & 0 deletions packages/core/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import memory from '@koishijs/plugin-database-memory'
import mock from '@koishijs/plugin-mock'
import { expect } from 'chai'
import { App } from 'koishi'

describe('wordle', () => {
const app = new App()

app.plugin(mock)
app.plugin(memory)

before(() => app.start())
after(() => app.stop())

it('should pass test', async () => {
expect(1).to.equal(1)
})
})
2 changes: 1 addition & 1 deletion packages/wordle/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export class Wordle extends WordleCore {
getTodayWord(): string {
return ''
}

validateInput(): WordleCore.Validation {
return {
isValid: false,
color: [],

}
}
}
Expand Down
22 changes: 22 additions & 0 deletions packages/wordle/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import memory from '@koishijs/plugin-database-memory'
import mock from '@koishijs/plugin-mock'
import { App } from 'koishi'

import * as wordle from '../src'

describe('wordle', () => {
const app = new App()

app.plugin(mock)
app.plugin(memory)
app.plugin(wordle)

const client = app.mock.client('123')

before(() => app.start())
after(() => app.stop())

it('get today wordle', async () => {
await client.shouldReply('wordle')
})
})
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"strictBindCallApply": true,
"jsx": "react-jsx",
"jsxImportSource": "@satorijs/element",
"types": ["yml-register/types"]
"types": ["mocha", "yml-register/types"]
}
}

0 comments on commit f7fc00d

Please sign in to comment.