Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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: ""
};
LeadOneFullWidthSlice: () => ({
__typename: "LeadOneFullWidthSlice",
items: mockEditionSlice(1)
}),
Markup: (parent, { maxCharCount }) => {
TileAN,
TileAR,
TileAS,
TileZ,
TileAF
} from "../src/tiles";
jest.mock("@times-components/article-flag", () => ({
ArticleFlags: "ArticleFlags"
}));
jest.mock("@times-components/image", () => "Image");
jest.mock("@times-components/link", () => "Link");
jest.mock("@times-components/gradient", () => "Gradient");
jest.mock("@times-components/article-label", () => "ArticleLabel");
const tile = mockEditionSlice(1).items[0];
const dailyRegisterItem = mockDailyRegisterSlice().birthdaysToday;
const testTile = (Tile, mockTile = tile) => {
const output = TestRenderer.create(
{}} tile={mockTile} />
);
expect(output).toMatchSnapshot();
};
const testPuzzleTile = Tile => {
const puzzle = mockPuzzleSlice();
const output = TestRenderer.create(
{}}
StandardSection: () => ({
colour: {
rgba: {
alpha: 1,
blue: 255,
green: 255,
red: 255
}
},
id: "dummy-section-id",
slices: [mockEditionSlice(1)],
slug: "dummy-section-slug",
title: "News"
}),
StandardSectionSlice: () => ({
TileX,
TileY,
TileZ,
TileAA,
TileAB,
TileAH,
TileAI,
TileAL,
TileAM,
TileAN,
TileAR,
TileAS,
TileAF
} from "./src/tiles";
const tile = mockEditionSlice(1).items[0];
const dailyRegisterItem = mockDailyRegisterSlice().birthdaysToday;
const preventDefaultedAction = decorateAction =>
decorateAction([
([e, ...args]) => {
e.preventDefault();
return ["[SyntheticEvent (storybook prevented default)]", ...args];
}
]);
const renderTile = (Tile, mockTile = tile) => (_, { decorateAction }) => (