How to use @times-components/fixture-generator - 10 common examples

To help you get started, we’ve selected a few @times-components/fixture-generator 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 / edition-slices / __tests__ / shared-slices.base.js View on Github external
},
  {
    mock: { puzzles: getPuzzleSlices(3) },
    name: "puzzle",
    Slice: PuzzleSlice
  }
];

const slicesWithPubLogo = [
  {
    mock: mockSecondaryOneAndFourSlice(),
    name: "secondary one and four",
    Slice: SecondaryOneAndFourSlice
  },
  {
    mock: mockLeadersSlice(),
    name: "leaders",
    Slice: LeadersSlice
  }
];

jest.mock("@times-components/utils", () => {
  // eslint-disable-next-line global-require
  const actualUtils = jest.requireActual("@times-components/utils");

  return {
    ...actualUtils,
    getDimensions: jest.fn(() => ({ height: 700, width: 500 }))
  };
});

const testsWithPublictaion = publicationName =>
github newsuk / times-components / packages / edition-slices / __tests__ / shared-tablet-slices.base.js View on Github external
mock: mockLeadOneAndFourSlice(),
    name: "lead one and four slice",
    Slice: LeadOneAndFourSlice
  },
  {
    mock: mockStandardSlice(),
    name: "standard slice",
    Slice: StandardSlice
  },
  {
    mock: mockSecondaryTwoNoPicAndTwoSlice(),
    name: "secondary two no pic and two",
    Slice: SecondaryTwoNoPicAndTwoSlice
  },
  {
    mock: mockListTwoAndSixNoPicSlice(),
    name: "list two and six no pic",
    Slice: ListTwoAndSixNoPicSlice
  },
  {
    mock: { puzzles: getPuzzleSlices(3) },
    name: "puzzle",
    Slice: PuzzleSlice
  }
];

jest.mock("@times-components/utils", () => {
  // eslint-disable-next-line global-require
  const actualUtils = jest.requireActual("@times-components/utils");

  return {
    ...actualUtils,
github newsuk / times-components / packages / edition-slices / __tests__ / shared-tablet-slices.base.js View on Github external
mock: mockStandardSlice(),
    name: "standard slice",
    Slice: StandardSlice
  },
  {
    mock: mockSecondaryTwoNoPicAndTwoSlice(),
    name: "secondary two no pic and two",
    Slice: SecondaryTwoNoPicAndTwoSlice
  },
  {
    mock: mockListTwoAndSixNoPicSlice(),
    name: "list two and six no pic",
    Slice: ListTwoAndSixNoPicSlice
  },
  {
    mock: { puzzles: getPuzzleSlices(3) },
    name: "puzzle",
    Slice: PuzzleSlice
  }
];

jest.mock("@times-components/utils", () => {
  // eslint-disable-next-line global-require
  const actualUtils = jest.requireActual("@times-components/utils");

  return {
    ...actualUtils,
    getDimensions: jest.fn()
  };
});

const tabletTester = type =>
github newsuk / times-components / packages / edition-slices / __tests__ / utils.base.js View on Github external
import { mockEditionSlice } from "@times-components/fixture-generator";
import {
  getTileImage,
  getTileSummary,
  getTileStrapline
} from "../src/tiles/shared";

const tile = mockEditionSlice(1).items[0];

jest.mock("@times-components/image", () => "TimesImage");

export default () => {
  describe("getTileImage should", () => {
    test("getTileImage - return null if there is no lead asset", () => {
      const tileWithoutLeadAsset = {
        ...tile,
        article: {
          ...tile.article,
          leadAsset: null,
          listingAsset: null
        },
        leadAsset: null
      };
      expect(getTileImage(tileWithoutLeadAsset, "crop169")).toEqual(null);
github newsuk / times-components / packages / ssr / __tests__ / helpers / article-helper.js View on Github external
it("does not have SpotIM comment tag when article comments are disabled", () => {
      const articleWithCommentsDisabled = new MockArticle()
        .sundayTimes()
        .setCommentsEnabled(false)
        .get();

      cy.task("startMockServerWith", {
        Article: articleWithCommentsDisabled,
        User: userWithBookmarks
      }).visit("/article/8763d1a0-ca57-11e8-bde6-fae32479843d");

      cy.get("script[data-spotim-module]").should("not.exist");
    });
github newsuk / times-components / packages / ssr / __tests__ / helpers / article-helper.js View on Github external
it("has SpotIM comment tag when article comments are enabled", () => {
      const articleWithCommentsEnabled = new MockArticle()
        .sundayTimes()
        .setCommentsEnabled(true)
        .get();

      cy.task("startMockServerWith", {
        Article: articleWithCommentsEnabled,
        User: userWithBookmarks
      }).visit("/article/8763d1a0-ca57-11e8-bde6-fae32479843d");

      cy.get("script[data-spotim-module]")
        .should("have.attr", "src", "https://launcher.spot.im/spot/5p0t_1m_1d")
        .should("have.attr", "data-post-id", articleWithCommentsEnabled.id)
        .should(
          "have.attr",
          "data-post-url",
          `https://www.thetimes.co.uk/article/${articleWithCommentsEnabled.id}`
github newsuk / times-components / packages / section / __tests__ / shared-tracking.js View on Github external
it("Save/Unsave article click tracking", () => {
    const edition = new MockEdition().get();
    const stream = jest.fn();
    const onArticlePress = jest.fn();
    const artickleId = edition.sections[0].slices[0].lead.article.id;
    const savedArticles = { artickleId: undefined };
    const onArticleSavePress = () => {
      savedArticles[artickleId] = !savedArticles[artickleId];
    };

    const testInstance = TestRenderer.create(
      
         {}}
          section={edition.sections[0]}
          stream={stream}
        />
github newsuk / times-components / packages / section / __tests__ / shared.js View on Github external
it("should render Secondary 2 No Pic and 2 instead of Secondary 2 and 2 for tablet", () => {
    const edition = new MockEdition().get();

    expect(
      TestRenderer.create(
        <section> {}}
          onArticlePress={() =&gt; {}}
          onPuzzleBarPress={() =&gt; {}}
          onPuzzlePress={() =&gt; {}}
          publicationName="TIMES"
          recentlyOpenedPuzzleCount={1}
          section={edition.sections[5]}
        /&gt;
      ).toJSON()
    ).toMatchSnapshot();
  });
</section>
github newsuk / times-components / packages / edition-slices / __tests__ / shared-components.base.js View on Github external
import { iterator } from "@times-components/test-utils";
import { mockEditionSlice } from "@times-components/fixture-generator";
import StarButton from "@times-components/star-button";
import { ResponsiveContext } from "@times-components/responsive";
import { editionBreakpoints } from "@times-components/styleguide";
import { TileH, TileX } from "../src/tiles";
import { TileLink, TileStar, TileSummary } from "../src/tiles/shared";
import { ResponsiveSlice } from "../src/slices/shared";

jest.mock("@times-components/article-flag", () => ({
  ArticleFlags: "ArticleFlags"
}));

jest.mock("@times-components/image", () => "TimesImage");

const tile = mockEditionSlice(1).items[0];

export default () => {
  const tests = [
    {
      name:
        "Tile summary falls back to article strapline if strapline is unavailable",
      test: () => {
        const tileWithoutStrapline = {
          ...tile,
          article: {
            ...tile.article,
            strapline: "This is strapline"
          },
          strapline: ""
        };
github newsuk / times-components / packages / provider-test-tools / src / edition.js View on Github external
LeadOneFullWidthSlice: () => ({
            __typename: "LeadOneFullWidthSlice",
            items: mockEditionSlice(1)
          }),
          Markup: (parent, { maxCharCount }) => {