test: Add unit tests for package/utils (#3357)

* Update return type to reflect actual signature

* add tests

* Set getDimensions as optional

* add newlines between specs

* remove redundant assertion

* move fixtures to separate files

* Add spacing

* Move tests, add cases

* Add unit tests for package/utils exportToSvg

* extract default object in test

* Move test suite to new file
This commit is contained in:
Hampus Lavin 2021-03-31 14:28:25 +02:00 committed by GitHub
parent bdf6e53289
commit 4ac1841d92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 437 additions and 2 deletions

View file

@ -11,7 +11,7 @@ import { restore } from "../data/restore";
type ExportOpts = {
elements: readonly ExcalidrawElement[];
appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
getDimensions: (
getDimensions?: (
width: number,
height: number,
) => { width: number; height: number; scale: number };
@ -83,7 +83,7 @@ export const exportToSvg = ({
appState = getDefaultAppState(),
exportPadding,
metadata,
}: ExportOpts & {
}: Omit<ExportOpts, "getDimensions"> & {
exportPadding?: number;
metadata?: string;
}): SVGSVGElement => {