flora-exception
Version:
An exception system for FQL.
36 lines (35 loc) • 1.52 kB
JavaScript
import { query } from "faunadb";
import { FaunaTestDb } from "fauna-test-setup";
import { Flora, } from "./Flora";
import { FloraException, ContainsException, IsException, GetExceptions } from "./Exception";
import { extractArgs } from "./Fx";
const { IsArray, Var, IsNumber, Do, And } = query;
export const ExceptionSuiteA = () => {
describe("Flora exceptions basic functionality", () => {
let db;
beforeAll(async () => {
db = await FaunaTestDb();
});
test("Is Exception", async () => {
const result = await db.client.query(IsException(FloraException()));
expect(result).toBe(true);
});
test("Contains Exception", async () => {
const result = await db.client.query(Flora(ContainsException([1, 2, FloraException()])));
expect(result).toBe(true);
});
test("Gets Exceptions", async () => {
const result = await db.client.query(Flora(GetExceptions([1, 2, FloraException(), 1, 2, FloraException(), 3])));
expect(result.length).toBe(2);
});
test("Gets complex Exceptions", async () => {
const args = [
[[2, 2, 2, 2], IsArray],
// ["dsfhks", IsArray as ()=>boolean]
];
const result = await db.client.query(Flora(extractArgs(args, "here")));
const secondResult = await db.client.query(Flora(ContainsException(extractArgs(args, "here"))));
});
});
};
ExceptionSuiteA();