Skip to content

Instantly share code, notes, and snippets.

@nicholasess
Created October 10, 2017 14:27
Show Gist options
  • Save nicholasess/1f1d46a4c311d716f61f5c4736c387da to your computer and use it in GitHub Desktop.
Save nicholasess/1f1d46a4c311d716f61f5c4736c387da to your computer and use it in GitHub Desktop.
snapshot
const Content = ({ content, handleVote}) => (
<Container>
<Info>
<Thumb
style={{
backgroundImage: `url(${changeImage.imageFromContent(
content.img_130
)})`
}}
/>
{content.voted ? (
<ButtonUnvote onClick={handleVote}>
<Icon icon={"i"} color={Color.green} />
{content.votes}
</ButtonUnvote>
) : (
<ButtonVote onClick={handleVote}>
<Icon icon={"&"} color={Color.white} />
{content.votes}
</ButtonVote>
)}
</Info>
<Info2>
<Title href={content.url}>{content.title}</Title>
<div>
<TypeIcon type={content.type} />
<Day>{content.published_at}</Day>
</div>
</Info2>
</Container>
);
Content.getDefaultProps = {
handleVote: () => {}
};
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`State initial of content 1`] = `
<div
className="sc-bwzfXH jhxTsW"
>
<div
className="sc-bZQynM jZVjBt"
>
<div
className="sc-htpNat rTBha"
style={
Object {
"backgroundImage": "url(https://welearnfs.s3.amazonaws.com/content_images/)",
}
}
/>
<div
className="sc-EHOje fIDzKW sc-bxivhb iSfDY"
onClick={undefined}
>
<span
className="icon sc-bdVaJa ecjBLC"
color="#fff"
data-icon="&"
/>
</div>
</div>
<div
className="sc-gzVnrw duPkhC"
>
<a
className="sc-htoDjs dFzTxy"
href={undefined}
/>
<div>
<span
className="icon sc-bdVaJa kftMBX"
color="#000"
data-icon="N"
/>
<span
className="sc-dnqmqq cKDwls"
/>
</div>
</div>
</div>
`;
import React from "react";
import Content from "./content";
import renderer from "react-test-renderer";
var content = {
img_130: ""
};
test("State initial of content", () => {
const inputInitial = renderer.create(<Content content={content} />);
let treeInputInitial = inputInitial.toJSON();
expect(treeInputInitial).toMatchSnapshot();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment