Skip to content

Commit

Permalink
feat: fix tests and move to all native test
Browse files Browse the repository at this point in the history
  • Loading branch information
spence-s committed Jan 14, 2024
1 parent 2a1bc28 commit c1d952f
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Expand Up @@ -19,9 +19,9 @@ jobs:
name: Node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run test
- run: npm test
1 change: 0 additions & 1 deletion .gitignore
@@ -1,6 +1,5 @@
node_modules
dist
*.vsix
.tsimp

coverage
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .xo-config.json
Expand Up @@ -16,6 +16,12 @@
"rules": {
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]
}
},
{
"files": "test/**/*.ts",
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -43,8 +43,8 @@
"lint": "xo && npm run lint:md",
"lint:md": "prettier --parser markdown '**/*.md' --check",
"prepare": "husky install",
"test:": "rimraf .tsimp && NODE_NO_WARNINGS=1 node --import tsimp/import --test test/native/**/*.ts",
"test:coverage": "rimraf .tsimp && NODE_NO_WARNINGS=1 c8 node --import tsimp/import --test test/native/**/*.ts",
"test": "NODE_NO_WARNINGS=1 node --require tsx/cjs --test test/index.ts",
"test:coverage": "NODE_NO_WARNINGS=1 c8 node --require tsx/cjs --test test/index.ts",
"vscode:prepublish": "npm run check && npm run build"
},
"contributes": {
Expand Down Expand Up @@ -212,7 +212,7 @@
"prettier": "^3.1.1",
"prettier-plugin-packagejson": "^2.4.9",
"rimraf": "^5.0.5",
"tsimp": "^2.0.10",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"webfont": "^6.0.2",
"xo": "^0.56.0"
Expand Down
20 changes: 6 additions & 14 deletions test/index.ts
@@ -1,15 +1,7 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import {test, describe} from 'node:test';
import assert from 'node:assert';
import Server from '../server/server.js';
/* eslint-disable import/no-unassigned-import */
// since globs are not fully supported in node v18 and v20 we import the files manually here

describe('Server', () => {
test('Server is a function', (t) => {
assert.strictEqual(typeof Server, 'function');
});

test('Server can instantiate', (t) => {
const server = new Server({isTest: true});
assert.strictEqual(typeof server, 'object');
});
});
// TODO: remove this file once node v21 is LTS
import './server.js';
import './lsp/document-sync.js';
import './lsp/initialization.js';
1 change: 0 additions & 1 deletion test/lsp/document-sync.ts
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import {test, describe, mock, type Mock} from 'node:test';
import assert from 'node:assert';
import {TextDocument} from 'vscode-languageserver-textdocument';
Expand Down
9 changes: 4 additions & 5 deletions test/lsp/initialization.ts
@@ -1,16 +1,15 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import {describe, test} from 'node:test';
import assert from 'node:assert';
import Server from '../../server/server.js';

const server = new Server({isTest: true});
describe('Server.handleInitialize', async () => {
const server = new Server({isTest: true});

describe('Server.handleInitialize', () => {
test('Server.handleInitialize is a function', (t) => {
await test('Server.handleInitialize is a function', (t) => {
assert.equal(typeof server.handleInitialize, 'function');
});

test('InitializeResult matches snapshot', async (t) => {
await test('InitializeResult matches snapshot', async (t) => {
const result = await server.handleInitialize();
assert.deepEqual(result, {
capabilities: {
Expand Down
14 changes: 14 additions & 0 deletions test/server.ts
@@ -0,0 +1,14 @@
import {test, describe} from 'node:test';
import assert from 'node:assert';
import Server from '../server/server.js';

describe('Server', () => {
test('Server is a function', (t) => {
assert.strictEqual(typeof Server, 'function');
});

test('Server can instantiate', (t) => {
const server = new Server({isTest: true});
assert.strictEqual(typeof server, 'object');
});
});

0 comments on commit c1d952f

Please sign in to comment.