Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
{
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 =>
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,
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 =>
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);
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");
});
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}`
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}
/>
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={() => {}}
onPuzzleBarPress={() => {}}
onPuzzlePress={() => {}}
publicationName="TIMES"
recentlyOpenedPuzzleCount={1}
section={edition.sections[5]}
/>
).toJSON()
).toMatchSnapshot();
});
</section>
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 }) => {