Skip to content

Commit

Permalink
refactor: remove unused ts-ignore
Browse files Browse the repository at this point in the history
ref #2856
  • Loading branch information
shaman-apprentice committed Jun 19, 2022
1 parent 762defd commit c9507df
Showing 1 changed file with 6 additions and 7 deletions.
@@ -1,6 +1,6 @@
import { TestBed } from "@angular/core/testing"
import { Export3DMapButtonComponent } from "./export3DMapButton.component"
import { fireEvent, render } from "@testing-library/angular"
import { fireEvent, render, screen } from "@testing-library/angular"
import { Export3DMapButtonModule } from "./export3DMapButton.module"
import { FileDownloader } from "../../util/fileDownloader"
import { ThreeSceneService } from "../codeMap/threeViewer/threeSceneService"
Expand Down Expand Up @@ -35,24 +35,23 @@ describe("Export3DMapButtonComponent", () => {
})

it("should start download on click", async function () {
const { container } = await render(Export3DMapButtonComponent, { excludeComponentDeclaration: true })
const { fixture } = await render(Export3DMapButtonComponent, { excludeComponentDeclaration: true })
// mock download and therefore only verify the Angular binding.
// A better approach would be, if the component would only fire an action
// and an https://ngrx.io/guide/effects would do the side effect and logic.
// Then we could test the logic in the effect without mocking a lot
// and the component wouldn't need to know anything about store values
// @ts-ignore
const mockedDownload = jest.spyOn(ng.probe(container).componentInstance, "downloadStlFile").mockImplementation(() => null)
const mockedDownload = jest.spyOn(fixture.componentInstance, "downloadStlFile").mockImplementation(() => null)

const downloadButton = container.querySelector(".export-3d-button")
const downloadButton = screen.getByRole("button")
expect(downloadButton).not.toBe(null)

fireEvent.click(downloadButton)
expect(mockedDownload).toHaveBeenCalledTimes(1)
})
it("should download STL file with the right file name", async function () {
const { container } = await render(Export3DMapButtonComponent, { excludeComponentDeclaration: true })
const downloadButton = container.querySelector(".export-3d-button")
await render(Export3DMapButtonComponent, { excludeComponentDeclaration: true })
const downloadButton = screen.getByRole("button")

const downloadData = jest.spyOn(FileDownloader, "downloadData").mockImplementation(() => null)
ThreeSceneService.mapMeshInstance = { getThreeMesh: jest.fn() } as unknown as CodeMapMesh
Expand Down

0 comments on commit c9507df

Please sign in to comment.