test: write test codes with gh workflow
This commit is contained in:
parent
d2d6b5f6e1
commit
ce0ca5988e
7 changed files with 56 additions and 5 deletions
21
.github/workflows/test.yml
vendored
Normal file
21
.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
- name: Setup node.js 20
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
cache: "pnpm"
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pnpm i --frozen-lockfile
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm test
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,5 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# PIIs included
|
|
||||||
tests
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
"build": "rimraf dist && tsc",
|
"build": "rimraf dist && tsc",
|
||||||
"lint": "biome check",
|
"lint": "biome check",
|
||||||
"release": "semantic-release",
|
"release": "semantic-release",
|
||||||
"prepack": "pnpm build"
|
"prepack": "pnpm build",
|
||||||
|
"test": "node -r ts-node/register --test tests/*.test.ts"
|
||||||
},
|
},
|
||||||
"keywords": ["comcigan", "parser", "typescript", "school", "korean"],
|
"keywords": ["comcigan", "parser", "typescript", "school", "korean"],
|
||||||
"author": "Starcea <stardev.uwu@gmail.com>",
|
"author": "Starcea <stardev.uwu@gmail.com>",
|
||||||
|
|
|
||||||
14
tests/School.test.ts
Normal file
14
tests/School.test.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import assert from 'node:assert'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { comcigan } from '.'
|
||||||
|
import { School } from '../src'
|
||||||
|
|
||||||
|
test('Search schools by name', async () => {
|
||||||
|
const schools = await comcigan.searchSchools('중학교')
|
||||||
|
assert(schools.length > 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Get school by name', async () => {
|
||||||
|
const school = await School.fromName('중학교')
|
||||||
|
assert(school)
|
||||||
|
})
|
||||||
15
tests/Timetable.test.ts
Normal file
15
tests/Timetable.test.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import assert from 'node:assert'
|
||||||
|
import test from 'node:test'
|
||||||
|
import { comcigan } from '.'
|
||||||
|
|
||||||
|
test('Get timetable by code', async () => {
|
||||||
|
const schools = await comcigan.searchSchools('중학교')
|
||||||
|
const timetable = await comcigan.getTimetable(schools[0].code)
|
||||||
|
assert(timetable)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Get timetable by school', async () => {
|
||||||
|
const schools = await comcigan.searchSchools('중학교')
|
||||||
|
const timetable = await schools[0].getTimetable()
|
||||||
|
assert(timetable)
|
||||||
|
})
|
||||||
3
tests/index.ts
Normal file
3
tests/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import Comcigan from '../src'
|
||||||
|
|
||||||
|
export const comcigan = new Comcigan()
|
||||||
|
|
@ -100,6 +100,6 @@
|
||||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src", "tests"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue