Skip to content

Commit

Permalink
Add a snapshot test for the recent listens page (#797)
Browse files Browse the repository at this point in the history
* Add a snapshot test

* Lint the test file

* Add the snapshot and fix test

* Actually write the snapshot
  • Loading branch information
paramsingh authored Apr 12, 2020
1 parent 00ffdf6 commit 1efcab9
Show file tree
Hide file tree
Showing 6 changed files with 1,127 additions and 9 deletions.
47 changes: 47 additions & 0 deletions listenbrainz/webserver/static/js/src/RecentListens.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from "react";
import { mount } from "enzyme";

import * as recentListensProfilePageProps from "./__mocks__/recentListensProfilePageProps.json";

import RecentListens, { ListensListMode } from "./RecentListens";

const {
apiUrl,
artistCount,
haveListenCount,
latestListenTs,
latestSpotifyUri,
listenCount,
listens,
mode,
nextListenTs,
previousListenTs,
profileUrl,
spotify,
user,
webSocketsServerUrl,
} = recentListensProfilePageProps;

const props = {
apiUrl,
artistCount,
haveListenCount,
latestListenTs,
latestSpotifyUri,
listenCount,
listens,
mode: mode as ListensListMode,
nextListenTs,
previousListenTs,
profileUrl,
spotify,
user,
webSocketsServerUrl,
};

describe("RecentListens", () => {
it("renders correctly on the profile page", () => {
const wrapper = mount(<RecentListens {...props} />);
expect(wrapper.html()).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion listenbrainz/webserver/static/js/src/RecentListens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface RecentListensProps {
latestSpotifyUri?: string;
listenCount?: string;
listens?: Array<Listen>;
mode: ListensListMode,
mode: ListensListMode;
nextListenTs?: number;
previousListenTs?: number;
profileUrl?: string;
Expand Down
Loading

0 comments on commit 1efcab9

Please sign in to comment.