-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
31,858 additions
and
13,245 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
3.56.1 | ||
3.57.0 |
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 |
---|---|---|
@@ -1,43 +1,48 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import TestRenderer from 'react-test-renderer'; | ||
import { GridItem } from '../../src/js/components/GridItem'; | ||
import { core } from '../state'; | ||
|
||
describe('<GridItem />', () => { | ||
jest.mock('react-redux', () => ({ | ||
useSelector: jest.fn(), | ||
useDispatch: () => jest.fn(), | ||
})); | ||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useHistory: () => ({ | ||
location: { | ||
pathname: 'iris.local:6680/iris/artist/123:abc', | ||
}, | ||
}), | ||
useLocation: () => ({ | ||
pathname: 'iris.local:6680/iris/artist/123:abc', | ||
}), | ||
})); | ||
|
||
describe('<GridItem />', () => { | ||
it('should handle album', () => { | ||
const item = { | ||
uri: 'spotify:album:alpha', | ||
name: 'One', | ||
}; | ||
const dom = shallow(<GridItem item={item} />); | ||
expect(dom.find('.grid__item__name').text()).toEqual('One'); | ||
expect(dom.find('.grid__item__secondary__content').length).toBe(1); | ||
const result = TestRenderer.create( | ||
<BrowserRouter> | ||
<GridItem item={core.items['local:album:md5:66fbea3593ba96a15a9d4188bebab50b']} /> | ||
</BrowserRouter> | ||
).toJSON(); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
it('should handle artist', () => { | ||
const item = { | ||
uri: 'spotify:artist:alpha', | ||
name: 'Alpha', | ||
followers: 123, | ||
albums_uris: ['spotify:album:beta'], | ||
}; | ||
const dom = shallow(<GridItem item={item} />); | ||
expect(dom.find('.grid__item__name').text()).toEqual('Alpha'); | ||
expect(dom.find('.grid__item__secondary__content').childAt(0).render().text()).toEqual('123 followers'); | ||
expect(dom.find('.grid__item__secondary__content').childAt(1).render().text()).toEqual('1 albums'); | ||
const result = TestRenderer.create( | ||
<BrowserRouter> | ||
<GridItem item={core.items['local:artist:md5:4f6e4f979e2c40c5e6ad1735804c29bc']} /> | ||
</BrowserRouter> | ||
).toJSON(); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
it('should handle playlist', () => { | ||
const item = { | ||
uri: 'spotify:playlist:alpha', | ||
name: 'One', | ||
tracks: [ | ||
{ uri: 'spotify:track:123' }, | ||
{ uri: 'spotify:track:456' }, | ||
], | ||
}; | ||
const dom = shallow(<GridItem item={item} />); | ||
expect(dom.find('.grid__item__name').text()).toEqual('One'); | ||
expect(dom.find('.grid__item__secondary__content').render().text()).toEqual('2 tracks'); | ||
const result = TestRenderer.create( | ||
<BrowserRouter> | ||
<GridItem item={core.items['m3u:Local%20tester.m3u8']} /> | ||
</BrowserRouter> | ||
).toJSON(); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); |
212 changes: 212 additions & 0 deletions
212
__tests__/components/__snapshots__/GridItem.test.js.snap
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,212 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<GridItem /> should handle album 1`] = ` | ||
<a | ||
className="grid__item grid__item--album " | ||
data-qa-file="Link" | ||
data-qa-node="RouterLink" | ||
href="/album/local%3Aalbum%3Amd5%3A66fbea3593ba96a15a9d4188bebab50b" | ||
onClick={[Function]} | ||
onContextMenu={[Function]} | ||
> | ||
<div | ||
className="thumbnail thumbnail--loaded thumbnail--medium grid__item__thumbnail" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
> | ||
<i | ||
className="icon icon--material thumbnail__placeholder" | ||
data-qa-file="Icon" | ||
data-qa-node="i" | ||
> | ||
album | ||
</i> | ||
<div | ||
className="thumbnail__image" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
style={ | ||
Object { | ||
"backgroundImage": "url(\\"/local/17338e740316f18dbb5e3331ac6be6c1-500x500.jpeg\\")", | ||
} | ||
} | ||
/> | ||
<div | ||
className="thumbnail__actions" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
/> | ||
</div> | ||
<div | ||
className="grid__item__name" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
Sirens of the Sea | ||
</div> | ||
<div | ||
className="grid__item__secondary" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
<ul | ||
className="grid__item__secondary__content details" | ||
data-qa-file="GridItem" | ||
data-qa-node="ul" | ||
> | ||
<li | ||
data-qa-file="GridItem" | ||
data-qa-node="li" | ||
> | ||
<span | ||
className="undefined links-sentence" | ||
data-qa-file="LinksSentence" | ||
data-qa-node="span" | ||
> | ||
<span | ||
data-qa-file="LinksSentence" | ||
data-qa-node="span" | ||
> | ||
<span | ||
data-qa-file="LinksSentence" | ||
data-qa-node="span" | ||
> | ||
Above & Beyond | ||
</span> | ||
</span> | ||
</span> | ||
</li> | ||
</ul> | ||
</div> | ||
</a> | ||
`; | ||
|
||
exports[`<GridItem /> should handle artist 1`] = ` | ||
<a | ||
className="grid__item grid__item--artist " | ||
data-qa-file="Link" | ||
data-qa-node="RouterLink" | ||
href="/artist/local%3Aartist%3Amd5%3A4f6e4f979e2c40c5e6ad1735804c29bc" | ||
onClick={[Function]} | ||
onContextMenu={[Function]} | ||
> | ||
<div | ||
className="thumbnail thumbnail--loaded thumbnail--medium grid__item__thumbnail" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
> | ||
<i | ||
className="icon icon--material thumbnail__placeholder" | ||
data-qa-file="Icon" | ||
data-qa-node="i" | ||
> | ||
perm_identity | ||
</i> | ||
<div | ||
className="thumbnail__image" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
style={ | ||
Object { | ||
"backgroundImage": "url(\\"https://i.scdn.co/image/4dc7080ef509c36203a131a0eab8dd5e4800d7c2\\")", | ||
} | ||
} | ||
/> | ||
<div | ||
className="thumbnail__actions" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
/> | ||
</div> | ||
<div | ||
className="grid__item__name" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
Above & Beyond | ||
</div> | ||
<div | ||
className="grid__item__secondary" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
<ul | ||
className="grid__item__secondary__content details" | ||
data-qa-file="GridItem" | ||
data-qa-node="ul" | ||
> | ||
<li | ||
data-qa-file="GridItem" | ||
data-qa-node="li" | ||
> | ||
2 albums | ||
</li> | ||
</ul> | ||
</div> | ||
</a> | ||
`; | ||
|
||
exports[`<GridItem /> should handle playlist 1`] = ` | ||
<a | ||
className="grid__item grid__item--playlist " | ||
data-qa-file="Link" | ||
data-qa-node="RouterLink" | ||
href="/playlist/m3u%3ALocal%20tester.m3u8" | ||
onClick={[Function]} | ||
onContextMenu={[Function]} | ||
> | ||
<div | ||
className="thumbnail thumbnail--loaded thumbnail--medium grid__item__thumbnail" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
> | ||
<i | ||
className="icon icon--material thumbnail__placeholder" | ||
data-qa-file="Icon" | ||
data-qa-node="i" | ||
> | ||
queue_music | ||
</i> | ||
<div | ||
className="thumbnail__image" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
style={ | ||
Object { | ||
"backgroundImage": "url(\\"null\\")", | ||
} | ||
} | ||
/> | ||
<div | ||
className="thumbnail__actions" | ||
data-qa-file="Thumbnail" | ||
data-qa-node="div" | ||
/> | ||
</div> | ||
<div | ||
className="grid__item__name" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
Local tester | ||
</div> | ||
<div | ||
className="grid__item__secondary" | ||
data-qa-file="GridItem" | ||
data-qa-node="div" | ||
> | ||
<ul | ||
className="grid__item__secondary__content details" | ||
data-qa-file="GridItem" | ||
data-qa-node="ul" | ||
> | ||
<li | ||
data-qa-file="GridItem" | ||
data-qa-node="li" | ||
> | ||
13 tracks | ||
</li> | ||
</ul> | ||
</div> | ||
</a> | ||
`; |
Oops, something went wrong.