Skip to content

Commit

Permalink
test: migrate to ts and chai@5 (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Feb 20, 2024
1 parent bc05bf6 commit 527961a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions .mocharc.yml
@@ -0,0 +1,9 @@
reporter: spec
loader:
# - ts-node/esm
require:
- ts-node/register
- chai/register-should.js

spec: ["test/*.ts"]
watch-files: ["lib"]
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -8,7 +8,7 @@
"build": "tsc -b",
"clean": "tsc -b --clean",
"eslint": "eslint .",
"test": "mocha test/index.js --require ts-node/register",
"test": "mocha",
"test-cov": "c8 --reporter=lcovonly npm run test"
},
"files": [
Expand All @@ -30,10 +30,12 @@
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@types/chai": "^4.3.11",
"@types/js-yaml": "^4.0.5",
"@types/mocha": "^10.0.6",
"@types/node": "^18.11.7",
"c8": "^9.1.0",
"chai": "^4.3.6",
"chai": "^5.0.0",
"eslint": "^8.23.1",
"eslint-config-hexo": "^5.0.0",
"mocha": "^10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions test/.eslintrc → test/.eslintrc.json
@@ -1,7 +1,7 @@
{
"extends": "hexo/test",
"extends": "hexo/ts-test",
"rules": {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-empty-function": 0
}
}
}
1 change: 0 additions & 1 deletion test/.mocharc.yml

This file was deleted.

6 changes: 2 additions & 4 deletions test/index.js → test/index.ts
@@ -1,9 +1,7 @@
'use strict';

const should = require('chai').should(); // eslint-disable-line
const yfm = require('../lib/front_matter.ts');

describe('Front-matter', () => {
const yfm = require('../lib/front_matter.ts');

describe('split', () => {
it('not string', () => {
Expand Down Expand Up @@ -373,7 +371,7 @@ describe('Front-matter', () => {
].join('\n');

const data = yfm.parse(str);
parseInt(data.date.getTime() / 1000, 10).should.eql(parseInt(unixTime / 1000, 10));
parseInt(String(data.date.getTime() / 1000), 10).should.eql(parseInt(String(unixTime / 1000), 10));
});
});

Expand Down
21 changes: 11 additions & 10 deletions tsconfig.json
Expand Up @@ -6,14 +6,15 @@
"outDir": "dist",
"declaration": true,
"esModuleInterop": true,
"types": [
"node"
]
"types": ["node"]
},
"include": [
"lib/front_matter.ts"
],
"exclude": [
"node_modules"
]
}
"include": ["lib/front_matter.ts"],
"exclude": ["node_modules"],

"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"types": ["node", "mocha", "chai"]
}
}
}

0 comments on commit 527961a

Please sign in to comment.