Skip to content

Commit

Permalink
fixing article-skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
ivazlopasa2 committed Oct 14, 2024
1 parent 6990c7f commit 6c6f069
Show file tree
Hide file tree
Showing 84 changed files with 4,539 additions and 4,355 deletions.
18 changes: 9 additions & 9 deletions packages/article-skeleton/ArticleSkeleton.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ const articles = [
article3,
article4,
article5,
article6,
].map((article) => article.data.article);
article6
].map(article => article.data.article);

const articleHeadlines = articles.reduce(
(result, { shortHeadline }, index) => ({ ...result, [shortHeadline]: index }),
{}
);

const commentingConfig = {
account: "sp_pCQgrRiN",
account: "sp_pCQgrRiN"
};

const preventDefaultedAction = (action) =>
const preventDefaultedAction = action =>
action([
([e, ...args]) => {
e.preventDefault();
return ["[SyntheticEvent (storybook prevented default)]", ...args];
},
}
]);

storiesOf("Composed/Article Skeleton", module).add("Article Selection", () => {
Expand All @@ -66,8 +66,8 @@ storiesOf("Composed/Article Skeleton", module).add("Article Selection", () => {
component: "ArticleSkeleton",
attrs: {
article_name: "Headline",
section_details: "Section",
},
section_details: "Section"
}
}}
>
<MockBookmarksProvider otherMocks={[]} delay={1000} articleId={data.id}>
Expand All @@ -82,8 +82,8 @@ storiesOf("Composed/Article Skeleton", module).add("Article Selection", () => {
articleDataFromRender={{
breadcrumbs: [
{ title: "World", url: "/world" },
{ title: "News", url: "/news" },
],
{ title: "News", url: "/news" }
]
}}
isPreview={false}
onAuthorPress={preventDefaultedAction(decorateAction)(
Expand Down
24 changes: 12 additions & 12 deletions packages/article-skeleton/__tests__/ad-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ export const adConfig = {
biddersConfig: {
bidders: {
amazon: {
accountId: "3360",
accountId: "3360"
},
appnexus: {
placementId: "5823281",
placementId: "5823281"
},
criteo: {
zoneMap: {
"120x600": "764877",
},
"120x600": "764877"
}
},
ix: {
siteId: "188830",
siteId: "188830"
},
pubmatic: {
accountId: "156034",
adSlotPrefix: "Thetimes",
adSlotPrefix: "Thetimes"
},
rubicon: {
accountId: "14062",
siteId: "70608",
zoneId: "335918",
},
zoneId: "335918"
}
},
bucketSize: 0.25,
maxBid: 15,
minPrice: 0.01,
timeout: 3000,
timeout: 3000
},
bidderSlots: ["header", "inline-ad"],
bidInitialiser: Promise.resolve(),
globalSlots: ["ad-pixel", "ad-pixelskin", "ad-pixelteads"],
networkId: "mockNetwork",
pageTargeting: {
title: "Title",
title: "Title"
},
slotTargeting: {
path: "/news",
},
path: "/news"
}
};
16 changes: 8 additions & 8 deletions packages/article-skeleton/__tests__/header-with-style.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const emptyArticle = {
leadAsset: null,
relatedArticleSlice: null,
standfirst: null,
topics: null,
topics: null
};

const renderArticle = (data, header) => (
<ContextProviderWithDefaults
value={{
theme: { scale: scales.medium, sectionColour: "#FF0000" },
theme: { scale: scales.medium, sectionColour: "#FF0000" }
}}
>
<ArticleSkeleton
Expand All @@ -42,7 +42,7 @@ const renderArticle = (data, header) => (
</ContextProviderWithDefaults>
);

export const snapshotTests = (renderComponent) => [
export const snapshotTests = renderComponent => [
{
name: "article with header",
test() {
Expand All @@ -54,18 +54,18 @@ export const snapshotTests = (renderComponent) => [
const article = articleFixture(emptyArticle);
const output = renderComponent(renderArticle(article), header);
expect(output).toMatchSnapshot();
},
},
}
}
];

export default (renderComponent) => {
export default renderComponent => {
const realIntl = Intl;

beforeEach(() => {
global.Intl = {
DateTimeFormat: () => ({
resolvedOptions: () => ({ timeZone: "Europe/London" }),
}),
resolvedOptions: () => ({ timeZone: "Europe/London" })
})
};
});

Expand Down
10 changes: 5 additions & 5 deletions packages/article-skeleton/__tests__/images-with-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
hoistStyleTransform,
minimaliseTransform,
minimalWebTransform,
stylePrinter,
stylePrinter
} from "@times-components/jest-serializer";
import "./mocks";
import shared from "./images.base";
Expand All @@ -32,14 +32,14 @@ export default () => {
beforeEach(() => {
global.Intl = {
DateTimeFormat: () => ({
resolvedOptions: () => ({ timeZone: "Europe/London" }),
}),
resolvedOptions: () => ({ timeZone: "Europe/London" })
})
};

const nuk = {
user: {
isLoggedIn: true,
},
isLoggedIn: true
}
};
global.nuk = nuk;
});
Expand Down
52 changes: 26 additions & 26 deletions packages/article-skeleton/__tests__/images.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const emptyArticle = {
leadAsset: null,
relatedArticleSlice: null,
standfirst: null,
topics: null,
topics: null
};

export default () =>
Expand All @@ -27,7 +27,7 @@ export default () =>
const output = TestRenderer.create(
<Context.Provider
value={{
user: { isLoggedIn: true },
user: { isLoggedIn: true }
}}
>
<ArticleSkeleton
Expand All @@ -45,12 +45,12 @@ export default () =>
display: "primary",
imageIndex: 1,
ratio: "3:2",
url: "https://image-2.io",
url: "https://image-2.io"
},
children: [],
name: "image",
},
],
name: "image"
}
]
})}
onAuthorPress={() => {}}
onCommentGuidelinesPress={() => {}}
Expand All @@ -66,15 +66,15 @@ export default () =>
);

expect(output).toMatchSnapshot();
},
}
},
{
name: "a fullwidth image",
test() {
const output = TestRenderer.create(
<Context.Provider
value={{
user: { isLoggedIn: true },
user: { isLoggedIn: true }
}}
>
<ArticleSkeleton
Expand All @@ -92,12 +92,12 @@ export default () =>
display: "fullwidth",
imageIndex: 1,
ratio: "3:2",
url: "https://image-2.io",
url: "https://image-2.io"
},
children: [],
name: "image",
},
],
name: "image"
}
]
})}
onAuthorPress={() => {}}
onCommentGuidelinesPress={() => {}}
Expand All @@ -113,15 +113,15 @@ export default () =>
);

expect(output).toMatchSnapshot();
},
}
},
{
name: "a secondary image",
test() {
const output = TestRenderer.create(
<Context.Provider
value={{
user: { isLoggedIn: true },
user: { isLoggedIn: true }
}}
>
<ArticleSkeleton
Expand All @@ -139,12 +139,12 @@ export default () =>
display: "secondary",
imageIndex: 1,
ratio: "3:2",
url: "https://image-2.io",
url: "https://image-2.io"
},
children: [],
name: "image",
},
],
name: "image"
}
]
})}
onAuthorPress={() => {}}
onCommentGuidelinesPress={() => {}}
Expand All @@ -160,15 +160,15 @@ export default () =>
);

expect(output).toMatchSnapshot();
},
}
},
{
name: "an inline image",
test() {
const output = TestRenderer.create(
<Context.Provider
value={{
user: { isLoggedIn: true },
user: { isLoggedIn: true }
}}
>
<ArticleSkeleton
Expand All @@ -186,12 +186,12 @@ export default () =>
display: "inline",
imageIndex: 1,
ratio: "9:4",
url: "https://image-inline.io",
url: "https://image-inline.io"
},
children: [],
name: "image",
},
],
name: "image"
}
]
})}
onAuthorPress={() => {}}
onCommentGuidelinesPress={() => {}}
Expand All @@ -207,6 +207,6 @@ export default () =>
);

expect(output).toMatchSnapshot();
},
},
}
}
]);
8 changes: 4 additions & 4 deletions packages/article-skeleton/__tests__/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
compose,
minimaliseTransform,
minimalWebTransform,
print,
print
} from "@times-components/jest-serializer";
import "./mocks";
import shared from "./images.base";
Expand All @@ -16,7 +16,7 @@ const omitProps = new Set([
"className",
"data-testid",
"responsiveLinkStyles",
"style",
"style"
]);

export default () => {
Expand All @@ -33,8 +33,8 @@ export default () => {
beforeEach(() => {
const nuk = {
user: {
isLoggedIn: true,
},
isLoggedIn: true
}
};
global.nuk = nuk;
});
Expand Down
8 changes: 4 additions & 4 deletions packages/article-skeleton/__tests__/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const jestConfigurator =
require("@times-components/jest-configurator-web").default;
const jestConfigurator = require("@times-components/jest-configurator-web")
.default;

const jc = jestConfigurator(__dirname);
jc.preset = "ts-jest";
jc.globals = {
"ts-jest": {
tsConfigFile: "./tsconfig.jest.json",
},
tsConfigFile: "./tsconfig.jest.json"
}
};

module.exports = jc;
Loading

0 comments on commit 6c6f069

Please sign in to comment.