Skip to content

Commit 516d221

Browse files
committed
Switch to vitest
1 parent c2e5b61 commit 516d221

11 files changed

+33
-37
lines changed

.mocharc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.eslintrc.json
2-
.mocharc.json
32
**/*.spec.ts
3+
lib/gherkin.ts
44
tsconfig.json

lib/append.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { expect } from "chai";
1+
import { describe, expect, test } from "vitest";
22
import * as JsonPointer from "./index.js";
33

44

55
describe("append", () => {
6-
it("should append a segment to a pointer", () => {
6+
test("should append a segment to a pointer", () => {
77
const subject = JsonPointer.append("bar", "/foo");
88
expect(subject).to.eql("/foo/bar");
99
});
1010

11-
it("should append a segment to the nil pointer", () => {
11+
test("should append a segment to the nil pointer", () => {
1212
const subject = JsonPointer.append("bar", JsonPointer.nil);
1313
expect(subject).to.eql("/bar");
1414
});
1515

16-
it("should escape a segment when it is appended to a pointer", () => {
16+
test("should escape a segment when it is appended to a pointer", () => {
1717
const subject = JsonPointer.append("b~a/r", "/foo");
1818
expect(subject).to.eql("/foo/b~0a~1r");
1919
});

lib/assign.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expect } from "chai";
2-
import { Given, When, Then } from "./mocha-gherkin.spec.js";
1+
import { beforeEach, describe, expect } from "vitest";
2+
import { Given, When, Then } from "./gherkin.js";
33
import * as JsonPointer from "./index.js";
44
import type { Json, JsonObject, Pointable } from "./index.js";
55

lib/get.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect } from "chai";
1+
import { beforeEach, describe, expect, test } from "vitest";
22
import * as JsonPointer from "./index.js";
33
import type { Getter } from "./index.js";
44

@@ -56,36 +56,36 @@ describe("JsonPointer", () => {
5656
ptr = JsonPointer.get(pointer);
5757
});
5858

59-
it(`should equal ${JSON.stringify(expected)}`, () => {
59+
test(`should equal ${JSON.stringify(expected)}`, () => {
6060
expect(ptr(subject)).to.eql(expected);
6161
});
6262
});
6363
});
6464
});
6565

6666
describe("indexing into a number", () => {
67-
it("should throw an error", () => {
67+
test("should throw an error", () => {
6868
const ptr = JsonPointer.get("//foo");
6969
expect(() => ptr(subject)).to.throw(Error, "Value at '/' is a number and does not have property 'foo'");
7070
});
7171
});
7272

7373
describe("indexing into a string", () => {
74-
it("should throw an error", () => {
74+
test("should throw an error", () => {
7575
const ptr = JsonPointer.get("/foo/0/0");
7676
expect(() => ptr(subject)).to.throw(Error, "Value at '/foo/0' is a string and does not have property '0'");
7777
});
7878
});
7979

8080
describe("indexing into a null", () => {
81-
it("should throw an error", () => {
81+
test("should throw an error", () => {
8282
const ptr = JsonPointer.get("/aaa/0");
8383
expect(() => ptr(subject)).to.throw(Error, "Value at '/aaa' is null and does not have property '0'");
8484
});
8585
});
8686

8787
describe("a pointer that doesn't start with '/'", () => {
88-
it("should throw an error", () => {
88+
test("should throw an error", () => {
8989
expect(() => JsonPointer.get("foo")).to.throw(Error, "Invalid JSON Pointer");
9090
});
9191
});

lib/gherkin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { describe, it } from "vitest";
2+
3+
import type { SuiteFactory, TestFunction } from "vitest";
4+
5+
6+
export const Given = (message: string, fn: SuiteFactory | undefined) => describe("Given " + message, fn);
7+
export const When = (message: string, fn: SuiteFactory | undefined) => describe("When " + message, fn);
8+
export const Then = (message: string, fn: TestFunction | undefined): void => {
9+
it("Then " + message, fn);
10+
};
11+
export const And = (message: string, fn: SuiteFactory | undefined) => describe("And " + message, fn);

lib/mocha-gherkin.spec.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/remove.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expect } from "chai";
2-
import { Given, When, Then } from "./mocha-gherkin.spec.js";
1+
import { beforeEach, describe, expect } from "vitest";
2+
import { Given, When, Then } from "./gherkin.js";
33
import * as JsonPointer from "./index.js";
44
import type { Json, JsonObject, Pointable } from "./index.js";
55

lib/set.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { beforeEach, describe } from "vitest";
12
import { expect } from "chai";
2-
import { Given, When, Then } from "./mocha-gherkin.spec.js";
3+
import { Given, When, Then } from "./gherkin.js";
34
import * as JsonPointer from "./index.js";
45
import type { Json, JsonObject, Pointable } from "./index.js";
56

lib/unset.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expect } from "chai";
2-
import { Given, When, Then } from "./mocha-gherkin.spec.js";
1+
import { beforeEach, describe, expect } from "vitest";
2+
import { Given, When, Then } from "./gherkin.js";
33
import * as JsonPointer from "./index.js";
44
import type { Json, JsonObject, Pointable } from "./index.js";
55

0 commit comments

Comments
 (0)