flora-exception
Version:
An exception system for FQL.
102 lines (83 loc) • 3.63 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.YieldSuiteA = void 0;
const fauna_test_setup_1 = require("fauna-test-setup");
// import { Yield } from "./Yield";
const faunadb_1 = require("faunadb");
const { Add } = faunadb_1.query;
const YieldSuiteA = () => {
describe("Flora exceptions basic functionality", () => {
let db;
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
db = yield (0, fauna_test_setup_1.FaunaTestDb)();
}));
test("Simple yield", () => __awaiter(void 0, void 0, void 0, function* () {
/* const result = await db.client.query(Flora(
Yield({
args : [2, 2],
expr : (a, b)=>{
return Add(2, 2)
}
})
))
expect(result).toBe(4);*/
}));
/* test("Yield within yield", async ()=>{
const InterestingFunc = (a : number) : number=>{
return Yield({
args : [a],
expr : (a)=>{
return Add(a, 2)
}
}) as unknown as number
}
const result = await db.client.query(Flora(
InterestingFunc(InterestingFunc(2))
))
expect(result).toBe(6);
})
test("Handles Exception in yield", async()=>{
const InterestingFunc = (a : number) : number=>{
return Yield({
args : [a],
expr : (a)=>{
return Add(a, 2)
}
}) as unknown as number
}
const result = await db.client.query<FloraExceptionI>(Flora(
InterestingFunc(FloraException() as unknown as number)
))
expect(isFloraException(result)).toBe(true);
expect(result.at?.length).toBe(1);
expect(result.location).toBe(InterestingFunc.name);
})
test("Handles Exception in yield in yield", async ()=>{
const InterestingFunc = (a : number) : number=>{
return Yield({
args : [a],
expr : (a)=>{
return Add(a, 2)
}
}) as unknown as number
}
const result = await db.client.query<FloraExceptionI>(Flora(
InterestingFunc(InterestingFunc(FloraException() as unknown as number))
))
expect(isFloraException(result)).toBe(true);
expect(result.at?.length).toBe(1);
expect(result.location).toBe(InterestingFunc.name);
})*/
});
};
exports.YieldSuiteA = YieldSuiteA;
(0, exports.YieldSuiteA)();