it("should return false if both propsImage and stateImage are different type of images", () => {
   assert.isFalse(ScreenshotUtils.isRemoteImageLocal(
     {path: "/path1", url: "blob://test"}, // state
     "test url 2" // props
   ));
   assert.isFalse(ScreenshotUtils.isRemoteImageLocal(
     {url: "https://test-url"}, // state
     {path: "/path1", data: new Blob([0])} // props
   ));
 });
 it("should return true if both propsImage and stateImage are equal blobs", () => {
   const blobPath = "/test-blob-path/test.png";
   assert.isTrue(ScreenshotUtils.isRemoteImageLocal(
     {path: blobPath, url: "blob://test"}, // state
     {path: blobPath, data: new Blob([0])} // props
   ));
 });
    it("should create a local image object with the correct properties if remoteImage is a normal image", () => {
      const imageUrl = "https://test-url";
      let localImageObject = ScreenshotUtils.createLocalImageObject(imageUrl);

      assert.notCalled(url.createObjectURL);
      assert.deepEqual(localImageObject, {url: imageUrl});
    });
 it("should return false if both propsImage and stateImage are different normal images", () => {
   assert.isFalse(ScreenshotUtils.isRemoteImageLocal(
     {url: "test url 1"}, // state
     "test url 2" // props
   ));
 });
 it("should return true if both propsImage and stateImage are equal normal images", () => {
   assert.isTrue(ScreenshotUtils.isRemoteImageLocal(
     {url: "test url"}, // state
     "test url" // props
   ));
 });
 it("should return false if propsImage is not present and stateImage is present", () => {
   assert.isFalse(ScreenshotUtils.isRemoteImageLocal({}, null));
 });
 it("should return true if both propsImage and stateImage are not present", () => {
   assert.isTrue(ScreenshotUtils.isRemoteImageLocal(null, null));
 });
    it("should not call revokeObjectURL if image is not a blob", () => {
      ScreenshotUtils.maybeRevokeBlobObjectURL({url: "https://test-url"});

      assert.notCalled(url.revokeObjectURL);
    });
    it("should call revokeObjectURL if image is a blob", () => {
      ScreenshotUtils.maybeRevokeBlobObjectURL({path: "/path1", url: "blob://test"});

      assert.calledOnce(url.revokeObjectURL);
    });
Exemplo n.º 10
0
    it("should create a local image object with the correct properties if remoteImage is a blob", () => {
      let localImageObject = ScreenshotUtils.createLocalImageObject({path: "/path1", data: new Blob([0])});

      assert.calledOnce(url.createObjectURL);
      assert.deepEqual(localImageObject, {path: "/path1", url: DEFAULT_BLOB_URL});
    });
Exemplo n.º 11
0
    it("should return null if no remoteImage is supplied", () => {
      let localImageObject = ScreenshotUtils.createLocalImageObject(null);

      assert.notCalled(url.createObjectURL);
      assert.equal(localImageObject, null);
    });
Exemplo n.º 12
0
 it("should return false if type does not match", () => {
   assert.isFalse(ScreenshotUtils.isBlob(false, state.blobImage));
   assert.isFalse(ScreenshotUtils.isBlob(false, state.normalImage));
   assert.isFalse(ScreenshotUtils.isBlob(true, props.blobImage));
   assert.isFalse(ScreenshotUtils.isBlob(true, props.normalImage));
 });
Exemplo n.º 13
0
 it("should return false if image is not a blob and type matches", () => {
   assert.isFalse(ScreenshotUtils.isBlob(true, state.normalImage));
   assert.isFalse(ScreenshotUtils.isBlob(false, props.normalImage));
 });
Exemplo n.º 14
0
 it("should return true if image is a blob and type matches", () => {
   assert.isTrue(ScreenshotUtils.isBlob(true, state.blobImage));
   assert.isTrue(ScreenshotUtils.isBlob(false, props.blobImage));
 });
Exemplo n.º 15
0
 it("should return false if image is null", () => {
   assert.isFalse(ScreenshotUtils.isBlob(true, null));
   assert.isFalse(ScreenshotUtils.isBlob(false, null));
 });