How to use @times-components/utils - 10 common examples

To help you get started, we’ve selected a few @times-components/utils 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 / src / image.android.js View on Github external
render() {
    const { uri, style, aspectRatio } = this.props;
    const { isLoaded } = this.state;
    // web handles missing protocols just fine, native doesn't. This evens out support.
    const cleanUri = addMissingProtocol(uri);
    const previewUri =
      !cleanUri || this.state.isHighResolutionLoaded
        ? null
        : `${cleanUri}&preview=true`; // TODO: Implement a separate uri for preview

    const props = {
      style: styles.imageBackground,
      onLoad: this.handleLoad
    };

    if (cleanUri) {
      props.source = { uri: cleanUri };
    }

    const previewProps = {
      ...props,
github newsuk / times-components / packages / tealium / __tests__ / shared.js View on Github external
it("sends multiple events", async () => {
        setup();

        const e1 = { component: "Page1" };
        const e2 = { component: "Page2" };

        sendScheduler.enqueue(e1);
        sendScheduler.enqueue(e2);

        await delayAndAdvance(1000);
        expect(global.window.tealiumTrack).toHaveBeenCalledTimes(2);
      });
github newsuk / times-components / packages / tealium / __tests__ / shared.js View on Github external
it("sends more events if they cannot be sent in time", async () => {
        setup();
        const timer = delay(2 * 60 * 1000);

        const e1 = { component: "Page1" };
        const e2 = { component: "Page2" };

        global.window.tealiumTrack = () => {
          advance(1 * 60 * 1000);
        };

        jest.spyOn(global.window, "tealiumTrack");

        sendScheduler.enqueue(e1);
        sendScheduler.enqueue(e2);

        await delayAndAdvance(0);
        await timer;
        expect(global.window.tealiumTrack).toHaveBeenCalledTimes(2);
github newsuk / times-components / packages / author-profile / __tests__ / author-profile.js View on Github external
test: async () => {
        const testInstance = TestRenderer.create(
          
            
          
        );

        await delay(1500);

        expect(testInstance).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / topic / __tests__ / topic-functional.js View on Github external
test: async () => {
        const testInstance = TestRenderer.create(
          
            
          
        );

        await delay(1500);

        expect(testInstance).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / tealium / __tests__ / shared.js View on Github external
setup();
        const timer = delay(2 * 60 * 1000);

        const e1 = { component: "Page1" };
        const e2 = { component: "Page2" };

        global.window.tealiumTrack = () => {
          advance(1 * 60 * 1000);
        };

        jest.spyOn(global.window, "tealiumTrack");

        sendScheduler.enqueue(e1);
        sendScheduler.enqueue(e2);

        await delayAndAdvance(0);
        await timer;
        expect(global.window.tealiumTrack).toHaveBeenCalledTimes(2);
      });
    });
github newsuk / times-components / packages / edition-slices / __tests__ / shared-tablet-slices.base.js View on Github external
test: () => {
      getDimensions.mockImplementation(() => ({
        width: editionBreakpointWidths[type]
      }));
      const output = TestRenderer.create(
        
           {}} slice={mock} />
        
      );

      expect(output).toMatchSnapshot();
    }
  }));
github newsuk / times-components / packages / tealium / __tests__ / shared.js View on Github external
global.window.tealiumTrack = () => {
          advance(1 * 60 * 1000);
        };
github newsuk / times-components / packages / article-main-standard / src / article-lead-asset / article-lead-asset-video.js View on Github external
const ArticleLeadAssetVideo = ({
  brightcoveVideoId,
  brightcovePolicyKey,
  brightcoveAccountId,
  posterImage,
  onVideoPress,
  skySports
}) => {
  const crop = getStandardTemplateCrop(posterImage);
  const { ratio, url } = crop;
  const [ratioWidth, ratioHeight] = ratio.split(":");
  const aspectRatio = ratioWidth / ratioHeight;

  const width = screenWidth();
  const height = width / aspectRatio;

  return (
    <video width="{width}" poster="{{" height="{height}">
  );
};
</video>
github newsuk / times-components / packages / article-main-standard / src / article-lead-asset / article-lead-asset-image.js View on Github external
const ArticleLeadAssetImage = ({
  caption,
  credits,
  crop11,
  crop23,
  crop32,
  crop45,
  crop169,
  crop1251,
  width
}) => {
  const crop = getStandardTemplateCrop({
    crop11,
    crop23,
    crop32,
    crop45,
    crop169,
    crop1251
  });

  if (crop === null) {
    return null;
  }

  const { ratio, url } = crop;
  const [ratioWidth, ratioHeight] = ratio.split(":");
  const aspectRatio = ratioWidth / ratioHeight;