How to use the @times-components/jest-serializer.replacePropTransform function in @times-components/jest-serializer

To help you get started, we’ve selected a few @times-components/jest-serializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newsuk / times-components / packages / image / __tests__ / shared.web.js View on Github external
export default () => {
  addSerializers(
    expect,
    compose(
      print,
      minimalWebTransform,
      minimaliseTransform(
        (value, key) => key === "style" || key === "className"
      ),
      replacePropTransform((value, key) => (key === "d" ? hash(value) : value))
    )
  );

  // eslint-disable-next-line global-require
  require("jest-styled-components");

  const tests = [
    {
      name: "an invalid uri",
      test: () => {
        const testRenderer = TestRenderer.create(
          <img>
        );

        expect(testRenderer).toMatchSnapshot();
      }
github newsuk / times-components / packages / watermark / __tests__ / shared.js View on Github external
export default () =&gt; {
  addSerializers(
    expect,
    enzymeTreeSerializer(),
    compose(
      print,
      minimalNativeTransform,
      replacePropTransform((value, key) =&gt; (key === "d" ? hash(value) : value))
    )
  );

  it("1. watermark", () =&gt; {
    const wrapper = shallow();

    expect(wrapper).toMatchSnapshot();
  });
};
github newsuk / times-components / packages / image / __tests__ / modal-shared.native.js View on Github external
export default () =&gt; {
  addSerializers(
    expect,
    compose(
      print,
      minimalNativeTransform,
      minimaliseTransform(
        (value, key) =&gt; key === "style" || key === "nativeBackgroundAndroid"
      ),
      replacePropTransform((value, key) =&gt; (key === "d" ? hash(value) : value))
    )
  );

  const props = {
    aspectRatio: 2,
    caption: ,
    uri: "http://example.com/image.jpg?crop=1016%2C677%2C0%2C0"
  };

  const tests = [
    {
      name: "modal image",
      async test() {
        const testInstance = TestRenderer.create();

        await act(async () =&gt; {
github newsuk / times-components / packages / icons / __tests__ / shared-colour.web.js View on Github external
export default () => {
  addSerializers(
    expect,
    enzymeRenderedSerializer(),
    compose(
      print,
      replaceTransform({
        svg: justChildren
      }),
      minimaliseTransform((value, key) => key !== "fill" && key !== "stroke"),
      replacePropTransform(
        (value, key) =>
          longKeysSet.has(key) ? hash(JSON.stringify(value)) : value
      )
    )
  );

  shared(mount);
};
github newsuk / times-components / packages / svgs / __tests__ / web / serializers.js View on Github external
flattenStyleTransform,
  minimalWebTransform,
  print,
  replacePropTransform
} from "@times-components/jest-serializer";
import { hash } from "@times-components/test-utils";

const longValues = new Set(["points"]);

addSerializers(
  expect,
  compose(
    print,
    flattenStyleTransform,
    minimalWebTransform,
    replacePropTransform(
      (value, key) =>
        longValues.has(key) ? hash(JSON.stringify(value)) : value
    )
  )
);
github newsuk / times-components / packages / icons / __tests__ / shared.native.js View on Github external
export default () => {
  addSerializers(
    expect,
    compose(
      print,
      flattenStyleTransform,
      minimaliseTransform((value, key) => key === "opacity"),
      replacePropTransform(
        (value, key) =>
          longKeysSet.has(key) ? hash(JSON.stringify(value)) : value
      )
    )
  );

  shared(TestRenderer.create);
};
github newsuk / times-components / packages / icons / __tests__ / shared-dim.web.js View on Github external
export default () => {
  addSerializers(
    expect,
    enzymeRenderedSerializer(),
    compose(
      print,
      replaceTransform({
        svg: propsNoChildren
      }),
      minimaliseTransform((value, key) => key === "style" || key === "viewBox"),
      replacePropTransform(
        (value, key) =>
          longKeysSet.has(key) ? hash(JSON.stringify(value)) : value
      )
    )
  );

  shared(mount);
};
github newsuk / times-components / packages / image / __tests__ / shared.native.js View on Github external
export default () => {
  addSerializers(
    expect,
    compose(
      print,
      minimalNativeTransform,
      minimaliseTransform(
        (value, key) => key === "style" || key === "nativeBackgroundAndroid"
      ),
      replacePropTransform((value, key) => (key === "d" ? hash(value) : value))
    )
  );

  const props = {
    aspectRatio: 2,
    highResSize: 900,
    uri: "http://example.com/image.jpg?crop=1016%2C677%2C0%2C0",
    relativeWidth: 0.5,
    relativeHeight: 0.4,
    relativeHorizontalOffset: 0.16666666666666666,
    relativeVerticalOffset: 0.2
  };

  const tests = [
    {
      name: "prepend https schema",
github newsuk / times-components / packages / icons / __tests__ / shared.web.js View on Github external
export default () => {
  addSerializers(
    expect,
    enzymeRenderedSerializer(),
    compose(
      print,
      minimaliseTransform((value, key) => key === "style"),
      replacePropTransform(
        (value, key) =>
          longKeysSet.has(key) ? hash(JSON.stringify(value)) : value
      )
    )
  );

  shared(mount);
};
github newsuk / times-components / packages / video / __tests__ / video-shared.native.js View on Github external
export default () => {
  addSerializers(
    expect,
    enzymeRenderedSerializer(),
    compose(
      print,
      minimalNativeTransform,
      minimaliseTransform(
        (value, key) =>
          key === "style" ||
          key === "nativeBackgroundAndroid" ||
          key.includes("Class")
      ),
      replacePropTransform((value, key) => {
        if (key === "uri") {
          return hash(value);
        }
        if (key === "source" && value.uri) {
          return hash(value.uri);
        }
        return value;
      })
    )
  );

  const tests = [
    {
      name: "video",
      test: () => {
        const testInstance = TestRenderer.create(