import "jest";
import { decode } from "../attrs";
import { box } from "../box";

describe(decode.name, () => {
  it("requires both iw and ih to emit imageSize", () => {
    expect(decode({ id: "0" })).toEqual({ id: "0", hidePreview: false });
    expect(decode({ id: "0", nw: 20 })).toEqual({ id: "0", hidePreview: false });
    expect(decode({ id: "0", nh: 40 })).toEqual({ id: "0", hidePreview: false });
    expect(decode({ id: "0", nw: 20, nh: 40 })).toEqual({ id: "0", hidePreview: false, naturalSize: box(20, 40) });
  });

  it("exposes type", () => {
    expect(decode({ id: "0" })).toEqual({ id: "0", hidePreview: false });
    expect(decode({ id: "0", t: "image/png" })).toEqual({ id: "0", hidePreview: false, type: "image/png" });
  });
});
