* wip - <PodcastArticle /> component.
* Added filler user avatar for other article types.
* Added <LoadingArticle /> component.
* wip
* wip on <Article /> component.
* Added <Article /> component to barrel file.
* Deleted assets from dummy storybook assets folder.
* Updated podcast article story avatar.
* More work on <Article /> component.
* Refactoring Storybook stories.
* Refactored so main component is just the <Article /> component.
* Added a missing video article property.
* Some refactoring of <Article /> component.
* Added Storybook knobs addon.
* Now <Article /> component supports an isBookmarked prop.
* Fixed podcast Storybook story.
* Made the knobs Storybook addon the first tab
* Added more <Article /> Storybook stories.
* More <Article /> component tweaks.
* Added publish time to <Article /> component stories.
* Made the timeAgo function compatible with Preact.
* Added loading="lazy" attribute to <img /> in <Article /> component.
* Added <Article /> Storybook story for past published date.
* Fixed publish date for <Article /> story data.
* Scrapped random avatars.
* Added snapshots for <Article /> component.
* Added snapshots for <LoadingArticle /> component.
* Now test article entities are shared.
* Fixed some wording of Storybook stories.
* Breaking up Article.jsx to make codeclimate happy.
* Now <Article /> component receives icon props.
* Added knobs for <Article /> icon props.
* Added *.stories.jsx to codeclimate exclusion list.
* Added **/*.stories.jsx to codeclimate exclusion list.
* Alright now we have the good glob for excluding Storybook from codeclimate 😆
* Added org headline changes from low hanging fruit PR.
* Updated <Article /> snapshot for org headline.
150 lines
3.6 KiB
JavaScript
150 lines
3.6 KiB
JavaScript
import { h } from 'preact';
|
|
import render from 'preact-render-to-json';
|
|
import { Article } from '..';
|
|
import {
|
|
article,
|
|
articleWithOrganization,
|
|
articleWithSnippetResult,
|
|
articleWithReadingTimeGreaterThan1,
|
|
articleWithReactions,
|
|
videoArticle,
|
|
articleWithComments,
|
|
podcastArticle,
|
|
podcastEpisodeArticle,
|
|
userArticle,
|
|
assetPath,
|
|
} from './utilities/articleUtilities';
|
|
import '../../../assets/javascripts/lib/xss';
|
|
import '../../../assets/javascripts/utilities/timeAgo';
|
|
|
|
const commonProps = {
|
|
reactionsIcon: assetPath('reactions-stack.png'),
|
|
commentsIcon: assetPath('comments-bubble.png'),
|
|
videoIcon: assetPath('video-camera.svg'),
|
|
};
|
|
|
|
describe('<Article /> component', () => {
|
|
it('should render a standard article', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={article}
|
|
currentTag="javascript"
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with an organization', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={articleWithOrganization}
|
|
currentTag="javascript"
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with a flare tag', () => {
|
|
const tree = render(
|
|
<Article {...commonProps} isBookmarked={false} article={article} />,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with a snippet result', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={articleWithSnippetResult}
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with a reading time', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={articleWithReadingTimeGreaterThan1}
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with reactions', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={articleWithReactions}
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with comments', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={articleWithComments}
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render as saved on reading list', () => {
|
|
const tree = render(
|
|
<Article {...commonProps} isBookmarked article={articleWithComments} />,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render a video article', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={videoArticle}
|
|
currentTag="javascript"
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render a video article with a flare tag', () => {
|
|
const tree = render(
|
|
<Article {...commonProps} isBookmarked={false} article={videoArticle} />,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render a podcast article', () => {
|
|
const tree = render(
|
|
<Article
|
|
{...commonProps}
|
|
isBookmarked={false}
|
|
article={podcastArticle}
|
|
/>,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render a podcast episode', () => {
|
|
const tree = render(
|
|
<Article isBookmarked={false} article={podcastEpisodeArticle} />,
|
|
);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render a user article', () => {
|
|
const tree = render(<Article article={userArticle} />);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
});
|