Skip to content

Commit

Permalink
Replaces mocha with jest
Browse files Browse the repository at this point in the history
  • Loading branch information
lynchjames committed Aug 30, 2023
1 parent 7b75fb1 commit df943dd
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"scripts": {
"dev": "rollup --config rollup.config.js -w",
"build": "rollup --config rollup.config.js",
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\" }' mocha -r ts-node/register -r ignore-styles -r jsdom-global/register tests/**/*.test.ts",
"coverage": "nyc -r lcov -e .ts -x \"*.test.ts\" npm run test"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@babel/preset-env": "^7.22.14",
"@babel/preset-typescript": "^7.22.11",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
Expand All @@ -22,6 +23,7 @@
"chai": "^4.3.4",
"cross-env": "^7.0.3",
"ignore-styles": "^5.0.1",
"jest": "^29.6.4",
"jsdom": "^16.6.0",
"jsdom-global": "^3.0.2",
"mocha": "^10.2.0",
Expand Down
11 changes: 5 additions & 6 deletions tests/doc.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'mocha';
import { assert } from 'chai';
import NRDoc from '../src/doc';
import { NoteRefactorSettings } from '../src/settings';
Expand All @@ -10,7 +9,7 @@ let content: string[] = [];

describe("Note content - Content Only", () => {

before(async () => {
beforeAll(async () => {
fileContents = await loadTestFile();
content = toArray(fileContents, 0, 15);
doc = new NRDoc(new NoteRefactorSettings(), undefined, undefined);
Expand All @@ -35,7 +34,7 @@ describe("Note content - Content Only", () => {

describe("Note content - Content Only - Normalize header levels", () => {

before(async () => {
beforeAll(async () => {
fileContents = await loadTestFile();
content = toArray(fileContents, 42, 51);
const settings = new NoteRefactorSettings();
Expand Down Expand Up @@ -67,7 +66,7 @@ describe("Note content - Content Only - Normalize header levels", () => {

describe("Note content - First Line as File Name, exclude first line", () => {

before(async () => {
beforeAll(async () => {
fileContents = await loadTestFile();
const settings = new NoteRefactorSettings();
settings.excludeFirstLineInNote = true;
Expand Down Expand Up @@ -106,7 +105,7 @@ describe("Note content - First Line as File Name, first line as heading", () =>
let fileContents:string = '';
let content: string[] = [];

before(async () => {
beforeAll(async () => {
fileContents = await loadTestFile();
const settings = new NoteRefactorSettings();
settings.includeFirstLineAsNoteHeading = true;
Expand Down Expand Up @@ -144,7 +143,7 @@ describe("Note content - First Line as File Name, first line as heading", () =>

describe("Note content - First Line as File Name, first line as heading (modified heading)", () => {

before(async () => {
beforeAll(async () => {
fileContents = await loadTestFile();
const settings = new NoteRefactorSettings();
settings.includeFirstLineAsNoteHeading = true;
Expand Down
9 changes: 4 additions & 5 deletions tests/file.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'mocha';
import { assert } from 'chai';
import { mockDate} from './mocks/date';
import NRFile from '../src/file';
Expand All @@ -12,7 +11,7 @@ describe("File Name Prefix", () => {
let resetDateMock:() => void;
let settings = new NoteRefactorSettings();

before(async () => {
beforeAll(async () => {
file = new NRFile(settings);
resetDateMock = mockDate(date);
});
Expand Down Expand Up @@ -53,7 +52,7 @@ describe("File Name Prefix", () => {
assert.equal(prefix, '');
});

after(() => {
afterAll(() => {
resetDateMock();
});
});
Expand All @@ -63,7 +62,7 @@ describe("File Name Sanitisation", () => {
let resetDateMock:() => void;
let settings = new NoteRefactorSettings();

before(async () => {
beforeAll(async () => {
file = new NRFile(settings);
resetDateMock = mockDate(date);
});
Expand Down Expand Up @@ -115,7 +114,7 @@ describe("File Name Sanitisation", () => {
});


after(() => {
afterAll(() => {
resetDateMock();
});
});
5 changes: 2 additions & 3 deletions tests/moment-date-regex.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'mocha';
import { assert } from 'chai';
import { mockDate } from './mocks/date'
import MomentDateRegex from '../src/moment-date-regex';
Expand All @@ -8,7 +7,7 @@ const momentRegex = new MomentDateRegex();
describe("Date formatting", () => {
let resetDateMock:() => void;

before(async () => {
beforeAll(async () => {
resetDateMock = mockDate(date);
});

Expand Down Expand Up @@ -54,7 +53,7 @@ describe("Date formatting", () => {
assert.equal(momentRegex.replace(input), expectedOuput);
});

after(() => {
afterAll(() => {
resetDateMock();
});
});
Expand Down
3 changes: 1 addition & 2 deletions tests/placeholder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'mocha';
import { assert } from 'chai';
import { NotePlaceholders } from '../src/placeholder';
let placholders = new NotePlaceholders();
Expand All @@ -8,7 +7,7 @@ let output: string = '';

describe("Regression - Issue 28", () => {

before(async () => {
beforeAll(async () => {
input = `{{new_note_content}}`;
replacement =
`# Issue 28 - New Note
Expand Down
1 change: 0 additions & 1 deletion tests/setings.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'mocha';
import { assert } from 'chai';
import { Location, NoteRefactorSettings } from '../src/settings';

Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSources": true,
"module": "ESNext",
"target": "es5",
"allowJs": true,
Expand Down

0 comments on commit df943dd

Please sign in to comment.