-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test format and diagnostics
- Loading branch information
1 parent
29bbaa1
commit 951fda1
Showing
25 changed files
with
1,545 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node: [lts/*] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set node version to ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run compile | ||
|
||
- name: Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { readFile } from 'fs/promises'; | ||
import { activate, getDocUri } from './helper'; | ||
import * as vscode from 'vscode'; | ||
import * as assert from 'assert'; | ||
|
||
suite('formatter should work', () => { | ||
test('formatting work', async () => { | ||
const names = [ | ||
'example-units', | ||
'example-vuepress' | ||
]; | ||
|
||
for (const name of names) { | ||
const docUri = getDocUri(`${name}.md`); | ||
const fixDocUri = getDocUri(`${name}-fixed.md`); | ||
const { doc } = await activate(docUri); | ||
|
||
const fixed = await readFile(fixDocUri.fsPath, 'utf8'); | ||
|
||
// format docUri | ||
await vscode.commands.executeCommand('editor.action.formatDocument'); | ||
const actual = doc.getText(); | ||
|
||
assert.equal(actual, fixed); | ||
} | ||
}); | ||
|
||
// FIXME: test format selection not work, still format whole text | ||
// test('formatting range work', async() => { | ||
// const lists = [ | ||
// { | ||
// name: 'example-units', | ||
// selections: [ | ||
// new vscode.Selection(0, 0, 5, 61), | ||
// new vscode.Selection(18, 0, 20, 27) | ||
// ] | ||
// }, | ||
// { | ||
// name: 'example-vuepress', | ||
// selections: [ | ||
// new vscode.Selection(1, 0, 1, 15) | ||
// ] | ||
// } | ||
// ]; | ||
|
||
// for (const item of lists) { | ||
// const { | ||
// name, | ||
// selections | ||
// } = item; | ||
|
||
// const { | ||
// doc, | ||
// editor, | ||
// } = await activate(getDocUri(`${name}.md`)); | ||
|
||
// const fixed = await readFile(getDocUri(`${name}-select-fixed.md`).fsPath, 'utf8'); | ||
|
||
// editor.selections = selections; | ||
// await vscode.commands.executeCommand('editor.action.formatSelection'); | ||
// const actual = doc.getText(); | ||
// assert.equal(actual, fixed); | ||
// } | ||
|
||
// }); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"zhlint.options": { | ||
"rules": { | ||
"preset": "default" | ||
} | ||
}, | ||
"[markdown]": { | ||
"editor.defaultFormatter": "kkopite.zhlint" | ||
} | ||
} |
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.