test(jslib): migrate from ava to jest
ci/woodpecker/push/woodpecker Pipeline failed
Details
ci/woodpecker/push/woodpecker Pipeline failed
Details
parent
4c3727451b
commit
ab17644b0d
|
@ -0,0 +1,5 @@
|
|||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
|
@ -15,18 +15,20 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build --verbose",
|
||||
"test": "pnpm build && ava",
|
||||
"test": "jest",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"author": "Tomáš Mládek <t@mldk.cz>",
|
||||
"license": "AGPL-3.0",
|
||||
"devDependencies": {
|
||||
"@types/debug": "^4.1.8",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@typescript-eslint/eslint-plugin": "latest",
|
||||
"@typescript-eslint/parser": "latest",
|
||||
"ava": "^3.15.0",
|
||||
"eslint": "^8.7.0",
|
||||
"eslint-plugin-ava": "^14.0.0",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +0,0 @@
|
|||
import test from "ava";
|
||||
import { Any, Query, Variable } from "./query";
|
||||
|
||||
test("query matches simple", (t) => {
|
||||
const query = Query.matches("entity", "attribute", "value");
|
||||
t.is(query.toString(), '(matches entity "attribute" "value")');
|
||||
});
|
||||
|
||||
test("query matches anything", (t) => {
|
||||
const query = Query.matches(Any, Any, Any);
|
||||
t.is(query.toString(), "(matches ? ? ?)");
|
||||
});
|
||||
|
||||
test("query matches array", (t) => {
|
||||
const query = Query.matches("entity", "attribute", ["value1", "value2"]);
|
||||
t.is(query.toString(), '(matches entity "attribute" (in "value1" "value2"))');
|
||||
});
|
||||
|
||||
test("query matches addresses", (t) => {
|
||||
const query = Query.matches("entity", "attribute", [
|
||||
"@address1",
|
||||
"@address2",
|
||||
]);
|
||||
t.is(
|
||||
query.toString(),
|
||||
'(matches entity "attribute" (in @address1 @address2))'
|
||||
);
|
||||
});
|
||||
|
||||
test("query matches numbers", (t) => {
|
||||
const query = Query.matches("entity", "attribute", [1, 2]);
|
||||
t.is(query.toString(), '(matches entity "attribute" (in 1 2))');
|
||||
});
|
||||
|
||||
test("query matches variables", (t) => {
|
||||
const query = Query.matches("entity", "attribute", Variable("a"));
|
||||
t.is(query.toString(), '(matches entity "attribute" ?a)');
|
||||
});
|
||||
|
||||
test("OR queries", (t) => {
|
||||
const query = Query.or(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2")
|
||||
);
|
||||
t.is(
|
||||
query.toString(),
|
||||
'(or (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))'
|
||||
);
|
||||
});
|
||||
|
||||
test("AND queries", (t) => {
|
||||
const query = Query.and(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2")
|
||||
);
|
||||
t.is(
|
||||
query.toString(),
|
||||
'(and (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))'
|
||||
);
|
||||
});
|
||||
|
||||
test("NOT query", (t) => {
|
||||
const query = Query.not(Query.matches("entity", "attribute1", "value2"));
|
||||
t.is(query.toString(), '(not (matches entity "attribute1" "value2"))');
|
||||
});
|
||||
|
||||
test("JOIN queries", (t) => {
|
||||
const query = Query.join(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2")
|
||||
);
|
||||
t.is(
|
||||
query.toString(),
|
||||
'(join (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))'
|
||||
);
|
||||
});
|
|
@ -0,0 +1,79 @@
|
|||
import { Any, Query, Variable } from "../src/query";
|
||||
|
||||
describe("query matches", () => {
|
||||
test("query matches simple", () => {
|
||||
const query = Query.matches("entity", "attribute", "value");
|
||||
expect(query.toString()).toBe('(matches entity "attribute" "value")');
|
||||
});
|
||||
|
||||
test("query matches anything", () => {
|
||||
const query = Query.matches(Any, Any, Any);
|
||||
expect(query.toString()).toBe("(matches ? ? ?)");
|
||||
});
|
||||
|
||||
test("query matches array", () => {
|
||||
const query = Query.matches("entity", "attribute", ["value1", "value2"]);
|
||||
expect(query.toString()).toBe(
|
||||
'(matches entity "attribute" (in "value1" "value2"))',
|
||||
);
|
||||
});
|
||||
|
||||
test("query matches addresses", () => {
|
||||
const query = Query.matches("entity", "attribute", [
|
||||
"@address1",
|
||||
"@address2",
|
||||
]);
|
||||
expect(query.toString()).toBe(
|
||||
'(matches entity "attribute" (in @address1 @address2))',
|
||||
);
|
||||
});
|
||||
|
||||
test("query matches numbers", () => {
|
||||
const query = Query.matches("entity", "attribute", [1, 2]);
|
||||
expect(query.toString()).toBe('(matches entity "attribute" (in 1 2))');
|
||||
});
|
||||
|
||||
test("query matches variables", () => {
|
||||
const query = Query.matches("entity", "attribute", Variable("a"));
|
||||
expect(query.toString()).toBe('(matches entity "attribute" ?a)');
|
||||
});
|
||||
});
|
||||
|
||||
describe("compound queries", () => {
|
||||
test("OR queries", () => {
|
||||
const query = Query.or(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2"),
|
||||
);
|
||||
expect(query.toString()).toBe(
|
||||
'(or (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))',
|
||||
);
|
||||
});
|
||||
|
||||
test("AND queries", () => {
|
||||
const query = Query.and(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2"),
|
||||
);
|
||||
expect(query.toString()).toBe(
|
||||
'(and (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))',
|
||||
);
|
||||
});
|
||||
|
||||
test("NOT query", () => {
|
||||
const query = Query.not(Query.matches("entity", "attribute1", "value2"));
|
||||
expect(query.toString()).toBe(
|
||||
'(not (matches entity "attribute1" "value2"))',
|
||||
);
|
||||
});
|
||||
|
||||
test("JOIN queries", () => {
|
||||
const query = Query.join(
|
||||
Query.matches("entity", "attribute1", "value2"),
|
||||
Query.matches("entity", "attribute2", "value2"),
|
||||
);
|
||||
expect(query.toString()).toBe(
|
||||
'(join (matches entity "attribute1" "value2") (matches entity "attribute2" "value2"))',
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue