Skip to content

Commit

Permalink
add test workflow
Browse files Browse the repository at this point in the history
- remove different query tests to query folder
- also fix one test case
  • Loading branch information
sailist committed Dec 29, 2024
1 parent ecf4a74 commit a34decb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install Dependencies
run: pnpm install

- name: Run Tests
run: pnpm test
2 changes: 1 addition & 1 deletion tests/imp.counter.test.ts → tests/query/counter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest';

import { AnchorEditor } from "../src/editor"
import { AnchorEditor } from "../../src/editor"

import { beforeEach } from 'vitest'
beforeEach((ctx) => {
Expand Down
8 changes: 4 additions & 4 deletions tests/query.test.ts → tests/query/neighbor.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest';
import { anchorToStrong, findNode } from "../src/helper"
import { anchorToStrong, findNode } from "../../src/helper"

import { AnchorQuery, SimpleNeighborResult } from "../src/query"
import { AnchorQuery, SimpleNeighborResult } from "../../src/query"

function stringifySimpleNeighborResult(result: SimpleNeighborResult) {
if (result.next) {
Expand Down Expand Up @@ -59,7 +59,7 @@ test("horizontalNeighbor/case1", () => {
direction: "left",
stride: "char",
},
}).error?.message).toEqual(editor.messages.AT_TEXT_NODE_BOUNDARY)
}).error?.message).toEqual(editor.messages.QUERY_ERROR.AT_TEXT_NODE_BOUNDARY)

expect(editor._getHorizontalNeighborCase1({
anchor: {
Expand All @@ -70,7 +70,7 @@ test("horizontalNeighbor/case1", () => {
direction: "right",
stride: "char",
},
}).error?.message).toEqual(editor.messages.AT_TEXT_NODE_BOUNDARY)
}).error?.message).toEqual(editor.messages.QUERY_ERROR.AT_TEXT_NODE_BOUNDARY)

})

Expand Down

0 comments on commit a34decb

Please sign in to comment.