-);
+ )
+};
diff --git a/app/javascript/articles/__stories__/Article.stories.jsx b/app/javascript/articles/__stories__/Article.stories.jsx
index c175567d1..0367cac81 100644
--- a/app/javascript/articles/__stories__/Article.stories.jsx
+++ b/app/javascript/articles/__stories__/Article.stories.jsx
@@ -1,6 +1,7 @@
import { h } from 'preact';
import { storiesOf } from '@storybook/react';
import { withKnobs, object, text, boolean } from '@storybook/addon-knobs/react';
+import { action } from '@storybook/addon-actions';
import { Article } from '..';
import {
article,
@@ -25,11 +26,16 @@ const ICONS = {
VIDEO_ICON: assetPath('video-camera.svg'),
};
+const commonProps = {
+ bookmarkClick: action('Saved/unsaved article'),
+};
+
storiesOf('Components/Article/Standard', module)
.addDecorator(withKnobs)
.addDecorator(articleDecorator)
.add('Default', () => (
(
(
(
(
(
(
(
(
(
(
(
(
(
+
+ ))
+ .add('Is on Reading List', () => (
+
+ ));
diff --git a/app/javascript/articles/__tests__/FeaturedArticle.test.jsx b/app/javascript/articles/__tests__/FeaturedArticle.test.jsx
new file mode 100644
index 000000000..b7696e1c4
--- /dev/null
+++ b/app/javascript/articles/__tests__/FeaturedArticle.test.jsx
@@ -0,0 +1,37 @@
+import { h } from 'preact';
+import render from 'preact-render-to-json';
+import { featuredArticle, assetPath } from './utilities/articleUtilities';
+import '../../../assets/javascripts/lib/xss';
+import '../../../assets/javascripts/utilities/timeAgo';
+import { FeaturedArticle } from '../FeaturedArticle';
+
+const commonProps = {
+ reactionsIcon: assetPath('reactions-stack.png'),
+ commentsIcon: assetPath('comments-bubble.png'),
+};
+
+describe(' component', () => {
+ it('should render a standard article', () => {
+ const tree = render(
+ ,
+ );
+ expect(tree).toMatchSnapshot();
+ });
+
+ it('should render a bookmarked featured article', () => {
+ const tree = render(
+ ,
+ );
+ expect(tree).toMatchSnapshot();
+ });
+});
diff --git a/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap b/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap
index 17b9fa134..70a7f3220 100644
--- a/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap
+++ b/app/javascript/articles/__tests__/__snapshots__/Article.test.jsx.snap
@@ -232,19 +232,17 @@ exports[` component should render a standard article 1`] = `
`;
@@ -421,19 +419,17 @@ exports[` component should render a video article 1`] = `
`;
@@ -553,19 +549,17 @@ exports[` component should render a video article with a flare tag 1`
`;
@@ -706,19 +700,17 @@ exports[` component should render as saved on reading list 1`] = `
`;
@@ -822,19 +814,17 @@ exports[` component should render with a flare tag 1`] = `
`;
@@ -938,19 +928,17 @@ exports[` component should render with a reading time 1`] = `
`;
@@ -1061,19 +1049,17 @@ exports[` component should render with a snippet result 1`] = `
`;
@@ -1181,19 +1167,17 @@ exports[` component should render with an organization 1`] = `
`;
@@ -1334,19 +1318,17 @@ exports[` component should render with comments 1`] = `
`;
@@ -1469,19 +1451,17 @@ exports[` component should render with reactions 1`] = `
`;
diff --git a/app/javascript/articles/__tests__/__snapshots__/ArticleLoading.test.jsx.snap b/app/javascript/articles/__tests__/__snapshots__/ArticleLoading.test.jsx.snap
index 0bc3fc185..fb72a9b54 100644
--- a/app/javascript/articles/__tests__/__snapshots__/ArticleLoading.test.jsx.snap
+++ b/app/javascript/articles/__tests__/__snapshots__/ArticleLoading.test.jsx.snap
@@ -2,7 +2,12 @@
exports[` should render 1`] = `
should render 1`] = `
`;
diff --git a/app/javascript/articles/__tests__/__snapshots__/FeaturedArticle.test.jsx.snap b/app/javascript/articles/__tests__/__snapshots__/FeaturedArticle.test.jsx.snap
new file mode 100644
index 000000000..350202ee0
--- /dev/null
+++ b/app/javascript/articles/__tests__/__snapshots__/FeaturedArticle.test.jsx.snap
@@ -0,0 +1,341 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` component should render a bookmarked featured article 1`] = `
+
- <% end %>
-<% else %>
- <% @stories.each_with_index do |story, i| %>
- <% next if story.id == @featured_story.id %>
- <% if !user_signed_in? && i == 4 %>
- <%= render "stories/sign_in_invitation" %>
+
+<% end %>
+
+
+
+
+ <% if @stories.any? %>
+ <% @stories.each_with_index do |story, i| %>
+ <% next if story.id == @featured_story.id %>
+ <% if !user_signed_in? && i == 4 %>
+ <%= render "stories/sign_in_invitation" %>
+ <% end %>
+ <%= render "articles/single_story", story: story %>
<% end %>
- <%= render "articles/single_story", story: story %>
+ <% if @stories.size > 1 %>
+
+ <% end %>
+
<% end %>
-<% end %>
-<% if @stories.size > 1 %>
-
-<% end %>
-
+
\ No newline at end of file
diff --git a/spec/requests/stories_index_spec.rb b/spec/requests/stories_index_spec.rb
index cdfe25aaf..2f58f9ec0 100644
--- a/spec/requests/stories_index_spec.rb
+++ b/spec/requests/stories_index_spec.rb
@@ -138,31 +138,6 @@ RSpec.describe "StoriesIndex", type: :request do
expect(response.body).not_to include(CGI.escapeHTML("Super-puper"))
end
end
-
- describe "when authenticated" do
- let(:user) { create(:user) }
-
- before do
- sign_in user
- end
-
- it "contains the stories correctly serialized" do
- # we control titles to avoid escaping errors with apostrophes and such
- article = create(:article, featured: true)
- article.update_columns(title: "abc")
-
- articles = create_list(:article, 2)
- articles.each { |a| a.update_columns(title: "abc") }
-
- get root_path
- expect(response).to have_http_status(:ok)
-
- stories = controller.instance_variable_get(:@stories) # cheating a bit ;)
- expected_result = ArticleDecorator.decorate_collection(stories).
- to_json(controller.class.const_get(:DEFAULT_HOME_FEED_ATTRIBUTES_FOR_SERIALIZATION))
- expect(response.body).to include(ERB::Util.html_escape(expected_result))
- end
- end
end
describe "GET query page" do