@@ -10,7 +10,6 @@ let widgetMock;
10
10
11
11
describe ( 'SoundCloud Component' , ( ) => {
12
12
beforeEach ( ( ) => {
13
-
14
13
/**
15
14
* Mock out SoundCloud widget API
16
15
*/
@@ -20,58 +19,58 @@ describe('SoundCloud Component', () => {
20
19
Events : {
21
20
PLAY : 'play' ,
22
21
PAUSE : 'pause' ,
23
- FINISH : 'finish'
24
- }
25
- }
22
+ FINISH : 'finish' ,
23
+ } ,
24
+ } ,
26
25
} ;
27
26
28
27
widgetMock = {
29
28
load : jest . genMockFunction ( ) ,
30
29
bind : jest . genMockFunction ( ) ,
31
- unbind : jest . genMockFunction ( )
30
+ unbind : jest . genMockFunction ( ) ,
32
31
} ;
33
32
34
33
createWidget . mockImplementation ( ( props , cb ) => cb ( widgetMock ) ) ;
35
34
} ) ;
36
35
37
36
describe ( 'instantiation' , ( ) => {
38
37
it ( 'should render a SoundCloud API ready iframe' , ( ) => {
39
- const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = '' /> ) ;
38
+ const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = "" /> ) ;
40
39
const iframe = ReactDOM . findDOMNode ( TestUtils . findRenderedDOMComponentWithTag ( soundcloud , 'iframe' ) ) ;
41
40
42
41
expect ( iframe . getAttribute ( 'id' ) ) . toBe ( 'react-sc-widget' ) ;
43
42
expect ( iframe . getAttribute ( 'src' ) ) . toBe ( 'https://w.soundcloud.com/player/?url=' ) ;
44
43
} ) ;
45
44
46
45
it ( 'should accept a custom iframe id' , ( ) => {
47
- const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = '' id = ' custom-id' /> ) ;
46
+ const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = "" id = " custom-id" /> ) ;
48
47
const iframe = ReactDOM . findDOMNode ( TestUtils . findRenderedDOMComponentWithTag ( soundcloud , 'iframe' ) ) ;
49
48
50
49
expect ( iframe . getAttribute ( 'id' ) ) . toBe ( 'custom-id' ) ;
51
50
} ) ;
52
51
53
52
it ( 'should create a new SoundCloud widget' , ( ) => {
54
- TestUtils . renderIntoDocument ( < SoundCloud url = '' /> ) ;
53
+ TestUtils . renderIntoDocument ( < SoundCloud url = "" /> ) ;
55
54
expect ( createWidget . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'react-sc-widget' ) ;
56
55
} ) ;
57
56
} ) ;
58
57
59
58
describe ( 'appearance' , ( ) => {
60
59
it ( 'should pass a set of `opts` into the widget' , ( ) => {
61
60
const opts = {
62
- buying : false
61
+ buying : false ,
63
62
} ;
64
63
65
- TestUtils . renderIntoDocument ( < SoundCloud url = '' opts = { opts } /> ) ;
64
+ TestUtils . renderIntoDocument ( < SoundCloud url = "" opts = { opts } /> ) ;
66
65
expect ( widgetMock . load . mock . calls [ 0 ] [ 1 ] ) . toEqual ( opts ) ;
67
66
} ) ;
68
67
69
68
it ( 'should readjust height if visual mode is enabled' , ( ) => {
70
69
const opts = {
71
- visual : true
70
+ visual : true ,
72
71
} ;
73
72
74
- const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = '' opts = { opts } /> ) ;
73
+ const soundcloud = TestUtils . renderIntoDocument ( < SoundCloud url = "" opts = { opts } /> ) ;
75
74
const iframe = ReactDOM . findDOMNode ( TestUtils . findRenderedDOMComponentWithTag ( soundcloud , 'iframe' ) ) ;
76
75
expect ( iframe . getAttribute ( 'height' ) ) . toBe ( '450' ) ;
77
76
} ) ;
@@ -81,12 +80,18 @@ describe('SoundCloud Component', () => {
81
80
class Container extends React . Component {
82
81
constructor ( ) {
83
82
this . state = {
84
- url : 'https://soundcloud.com/sylvanesso/coffee'
83
+ url : 'https://soundcloud.com/sylvanesso/coffee' ,
85
84
} ;
86
85
87
86
this . _changeUrl = this . _changeUrl . bind ( this ) ;
88
87
}
89
88
89
+ _changeUrl ( ) {
90
+ this . setState ( {
91
+ url : 'https://soundcloud.com/hudsonmohawke/chimes' ,
92
+ } ) ;
93
+ }
94
+
90
95
render ( ) {
91
96
return (
92
97
< div >
@@ -95,12 +100,6 @@ describe('SoundCloud Component', () => {
95
100
</ div >
96
101
) ;
97
102
}
98
-
99
- _changeUrl ( ) {
100
- this . setState ( {
101
- url : 'https://soundcloud.com/hudsonmohawke/chimes'
102
- } ) ;
103
- }
104
103
}
105
104
106
105
it ( 'should load a `url`' , ( ) => {
@@ -137,22 +136,21 @@ describe('SoundCloud Component', () => {
137
136
describe ( 'events' , ( ) => {
138
137
it ( 'should bind event handler props to playback events' , ( ) => {
139
138
const playFn = ( ) => { } ;
140
- TestUtils . renderIntoDocument ( < SoundCloud url = '' onPlay = { playFn } /> ) ;
139
+ TestUtils . renderIntoDocument ( < SoundCloud url = "" onPlay = { playFn } /> ) ;
141
140
142
141
expect ( widgetMock . bind . mock . calls . length ) . toBe ( 3 ) ;
143
142
expect ( widgetMock . bind . mock . calls [ 0 ] ) . toContain ( playFn ) ;
144
143
} ) ;
145
144
146
145
it ( 'should remove event bindings when unmounted' , ( ) => {
147
-
148
146
/**
149
147
* `TestUtils.renderIntoDocument` renders the component into
150
148
* a detached DOM node, which makes it difficult to unmount.
151
149
*
152
150
* Instead, we'll just render it the old fashioned way.
153
151
*/
154
152
155
- ReactDOM . render ( < SoundCloud url = '' /> , document . body ) ;
153
+ ReactDOM . render ( < SoundCloud url = "" /> , document . body ) ;
156
154
ReactDOM . unmountComponentAtNode ( document . body ) ;
157
155
158
156
expect ( widgetMock . unbind . mock . calls . length ) . toBe ( 3 ) ;
0 commit comments