mirror of
https://github.com/wassname/talk.git
synced 2026-07-17 11:33:39 +08:00
More unit tests
This commit is contained in:
@@ -12,6 +12,8 @@ it("renders username and body", () => {
|
||||
},
|
||||
body: "Woof",
|
||||
createdAt: "1995-12-17T03:24:00.000Z",
|
||||
topBarRight: "topBarRight",
|
||||
footer: "footer",
|
||||
};
|
||||
const wrapper = shallow(<Comment {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
@@ -15,8 +15,8 @@ export interface CommentProps {
|
||||
} | null;
|
||||
body: string | null;
|
||||
createdAt: string;
|
||||
topBarRight?: ReactElement<any> | Array<ReactElement<any>>;
|
||||
footer?: ReactElement<any> | Array<ReactElement<any>>;
|
||||
topBarRight?: React.ReactNode;
|
||||
footer?: React.ReactNode;
|
||||
}
|
||||
|
||||
const Comment: StatelessComponent<CommentProps> = props => {
|
||||
|
||||
@@ -18,6 +18,9 @@ exports[`renders username and body 1`] = `
|
||||
1995-12-17T03:24:00.000Z
|
||||
</Timestamp>
|
||||
</TopBarLeft>
|
||||
<div>
|
||||
topBarRight
|
||||
</div>
|
||||
</withPropsOnChange(Flex)>
|
||||
<HTMLContent>
|
||||
Woof
|
||||
@@ -26,6 +29,8 @@ exports[`renders username and body 1`] = `
|
||||
className="Comment-footer"
|
||||
direction="row"
|
||||
itemGutter="half"
|
||||
/>
|
||||
>
|
||||
footer
|
||||
</withPropsOnChange(Flex)>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -12,7 +12,6 @@ exports[`renders correctly 1`] = `
|
||||
}
|
||||
body="Woof"
|
||||
createdAt="1995-12-17T03:24:00.000Z"
|
||||
id="comment-id"
|
||||
/>
|
||||
</Indent>
|
||||
`;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import timekeeper from "timekeeper";
|
||||
import isBeforeDate from "./isBeforeDate";
|
||||
|
||||
it("works correctly", () => {
|
||||
timekeeper.freeze(new Date("2018-07-06T18:24:00.000Z"));
|
||||
expect(isBeforeDate(new Date("2018-07-06T18:24:30.000Z"))).toBe(true);
|
||||
expect(isBeforeDate(new Date("2018-07-06T18:23:30.000Z"))).toBe(false);
|
||||
timekeeper.reset();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user