fixing forceAppendix null check & adding test
This commit is contained in:
parent
0963cafeda
commit
b07e834997
2 changed files with 11 additions and 1 deletions
|
|
@ -282,7 +282,7 @@ func Render(args []js.Value) (interface{}, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &WASMError{Message: fmt.Sprintf("render failed: %s", err.Error()), Code: 500}
|
return nil, &WASMError{Message: fmt.Sprintf("render failed: %s", err.Error()), Code: 500}
|
||||||
}
|
}
|
||||||
if input.Opts != nil && *input.Opts.ForceAppendix {
|
if input.Opts != nil && *&input.Opts.ForceAppendix != nil && *input.Opts.ForceAppendix {
|
||||||
out = appendix.Append(input.Diagram, renderOpts, ruler, out)
|
out = appendix.Append(input.Diagram, renderOpts, ruler, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,16 @@ describe("D2 Unit Tests", () => {
|
||||||
await d2.worker.terminate();
|
await d2.worker.terminate();
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
|
test("force appendix works", async () => {
|
||||||
|
const d2 = new D2();
|
||||||
|
const result = await d2.compile("x: {tooltip: x appendix}", { forceAppendix: true });
|
||||||
|
const svg = await d2.render(result.diagram, { forceAppendix: true });
|
||||||
|
expect(svg).toContain("<svg");
|
||||||
|
expect(svg).toContain("</svg>");
|
||||||
|
expect(svg).toContain('class="appendix"');
|
||||||
|
await d2.worker.terminate();
|
||||||
|
}, 20000);
|
||||||
|
|
||||||
test("latex works", async () => {
|
test("latex works", async () => {
|
||||||
const d2 = new D2();
|
const d2 = new D2();
|
||||||
const result = await d2.compile("x: |latex \\frac{f(x+h)-f(x)}{h} |");
|
const result = await d2.compile("x: |latex \\frac{f(x+h)-f(x)}{h} |");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue