File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import {
2+ moduleForComponent ,
3+ test
4+ }
5+ from 'ember-qunit' ;
6+ import Ember from 'ember' ;
7+
8+ moduleForComponent ( 'ember-filepicker' , {
9+ // specify the other units that are required for this test
10+ needs : [ 'service:filepicker' ]
11+ } ) ;
12+
13+ test ( 'it renders' , function ( assert ) {
14+ assert . expect ( 2 ) ;
15+
16+ // creates the component instance
17+ var component = this . subject ( ) ;
18+ assert . equal ( component . _state , 'preRender' ) ;
19+
20+ // renders the component to the page
21+ this . render ( ) ;
22+ assert . equal ( component . _state , 'inDOM' ) ;
23+ } ) ;
24+
25+ test ( 'it opens filepicker on component element insertion' , function ( assert ) {
26+ var component = this . subject ( ) ;
27+
28+ return new Ember . RSVP . Promise ( function ( resolve , reject ) {
29+ var subscriber ,
30+ interval = 100 ,
31+ counter = - 1 * interval ,
32+ timeout = 10000 ;
33+
34+ subscriber = window . setInterval ( function ( ) {
35+ counter += interval ;
36+ if ( timeout > counter ) {
37+ if ( $ ( '#filepicker_dialog' ) . length === 1 ) {
38+ resolve ( ) ;
39+ window . clearInterval ( subscriber ) ;
40+ }
41+ } else {
42+ reject ( ) ;
43+ }
44+ } , interval ) ;
45+ } ) . then ( function ( ) {
46+ assert . ok ( true ) ;
47+ } ) . catch ( function ( ) {
48+ assert . ok ( false , 'Filepicker dialog did not load on component element insertion' ) ;
49+ } ) ;
50+ } ) ;
You can’t perform that action at this time.
0 commit comments