UNPKG

quilon

Version:

Generate ERDs from your entity files automagically

37 lines (36 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const mockEntity_1 = require("./fixtures/mockEntity"); const Mermaid_1 = require("./Mermaid"); const mermaidBuilder = new Mermaid_1.MermaidBuilder(); describe("Mermaid", () => { it("should be defined", () => { expect(mermaidBuilder).toBeDefined(); }); describe("appendEntity", () => { it("should append the entity to the diagram", () => { const resultPattern = new RegExp(` erDiagram\\s* MockEntity \\{\\s* varchar id\\s* integer age\\s* \\}\\s* MockEntity \\|\\|--o\\{ RelatedEntity: "OneToMany" ` .trim() .replace(/\s+/g, "\\s*")); mermaidBuilder.appendEntity(mockEntity_1.mockEntity); const diagram = mermaidBuilder.getDiagram(); expect(diagram).toMatch(resultPattern); }); }); it("should call the correct private methods", () => { const appendTableNameSpy = jest.spyOn(mermaidBuilder, "appendTableName"); const appendColumnsSpy = jest.spyOn(mermaidBuilder, "appendColumns"); const appendRelationsSpy = jest.spyOn(mermaidBuilder, "appendRelations"); mermaidBuilder.appendEntity(mockEntity_1.mockEntity); expect(appendTableNameSpy).toHaveBeenCalledWith(mockEntity_1.mockEntity); expect(appendColumnsSpy).toHaveBeenCalledWith(mockEntity_1.mockEntity); expect(appendRelationsSpy).toHaveBeenCalledWith(mockEntity_1.mockEntity); }); });