forked from nukeop/nuclear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/dashboard tests (nukeop#910)
* WIP * Hoist dependencies * Fix jest config for hoisted dependencies * Jest config for core * Update typings location
- Loading branch information
Showing
31 changed files
with
119,492 additions
and
65,672 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/app/app/components/LibraryView/LibraryFolders/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/app/app/containers/DashboardContainer/DashboardContainer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
import { waitFor } from '@testing-library/react'; | ||
import { buildStoreState } from '../../../test/storeBuilders'; | ||
import { mountedComponentFactory, setupI18Next } from '../../../test/testUtils'; | ||
|
||
describe('Dashboard container', () => { | ||
beforeAll(() => { | ||
setupI18Next(); | ||
}); | ||
|
||
it('should display the best new music page of the dashboard', () => { | ||
const { component } = mountComponent(); | ||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should go to best new album review after clicking it', () => { | ||
const { component } = mountComponent(); | ||
|
||
waitFor(() => component.getByText(/test title 2/i).click()); | ||
|
||
expect(component.queryByText(/test review 2/i)).not.toBeNull(); | ||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should go to best new track review after clicking it', () => { | ||
const { component } = mountComponent(); | ||
|
||
waitFor(() => component.getByText(/test track title 2/i).click()); | ||
|
||
expect(component.queryByText(/track review 2/i)).not.toBeNull(); | ||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should add/remove a best new track to favorites after clicking its star', async () => { | ||
const { component, store } = mountComponent(); | ||
|
||
const addOrRemove = () => waitFor( | ||
() => component | ||
.getByTestId('favorite-icon-test track artist 1-test track title 1') | ||
.click() | ||
); | ||
|
||
await addOrRemove(); | ||
|
||
const state = store.getState(); | ||
expect(state.favorites.tracks).toEqual([ | ||
expect.objectContaining({ | ||
artist: { | ||
name: 'test track artist 1' | ||
}, | ||
name: 'test track title 1' | ||
}) | ||
]); | ||
|
||
await addOrRemove(); | ||
|
||
expect(state.favorites.tracks).toEqual([]); | ||
}); | ||
|
||
it('should, display top tracks after going to top tracks tab', async () => { | ||
const { component } = mountComponent(); | ||
|
||
await waitFor(() => component.getByText(/top tracks/i).click()); | ||
|
||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should, display genres after going to genres tab', async () => { | ||
const { component } = mountComponent(); | ||
|
||
await waitFor(() => component.getByText(/genres/i).click()); | ||
|
||
expect(component.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
const mountComponent = mountedComponentFactory( | ||
['/dashboard'], | ||
buildStoreState() | ||
.withDashboard() | ||
.withPlugins() | ||
.withConnectivity() | ||
.build() | ||
); | ||
}); |
Oops, something went wrong.