Commit 38ef330f authored by Diegodlh's avatar Diegodlh
Browse files

Test that citations are not made for non-applicable template outputs

parent ededc8d2
import { Webpage } from "../webpage/webpage";
import { Domain } from "./domain";
describe("Domain class", () => {
......@@ -5,3 +6,72 @@ describe("Domain class", () => {
expect(new Domain("example.com").domain).toBe("example.com");
});
});
it("does not make citatations for non-applicable template outputs", async () => {
const domain = new Domain("example.com", {
templates: [
{
path: "/template2",
label: "non-applicable",
fields: [
{
fieldname: "itemType",
required: true,
procedures: [
{
selections: [],
transformations: [],
},
],
},
{
fieldname: "title",
required: true,
procedures: [
{
selections: [],
transformations: [],
},
],
},
],
},
{
path: "/template1",
label: "applicable",
fields: [
{
fieldname: "itemType",
required: true,
procedures: [
{
selections: [{ type: "fixed", config: "webpage" }],
transformations: [],
},
],
},
{
fieldname: "title",
required: true,
procedures: [
{
selections: [{ type: "fixed", config: "title" }],
transformations: [],
},
],
},
],
},
],
});
const target = new Webpage("https://example.com/target");
const translationOutput = await domain.translate(target, {
onlyApplicable: false,
});
const templateOutputs = translationOutput.translation.outputs;
expect(templateOutputs.length).toBe(2);
expect(templateOutputs[0].template.applicable).toBe(false);
expect(templateOutputs[0].citation).toBeUndefined();
expect(templateOutputs[1].template.applicable).toBe(true);
expect(templateOutputs[1].citation).toBeDefined();
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment