@@ -19,24 +19,38 @@ describe('CSS', function() {
19
19
20
20
this . timeout ( 5000 ) ;
21
21
22
- it ( 'should have systemjs loaded ' , function ( ) {
22
+ it ( 'should load systemjs' , function ( ) {
23
23
assert . ok ( typeof window . System === 'object' ) ;
24
24
} ) ;
25
25
26
- it ( 'should load test.css' , function ( done ) {
27
- System . import ( '../test/test.css' ) . then ( function ( ) {
28
- done ( ) ;
26
+ it ( 'should load test_1.css' , function ( done ) {
27
+ System . import ( '../test/test_1.css' ) . then ( function ( ) {
28
+ let links = document . head . querySelectorAll ( 'link' ) ;
29
+ for ( var i = 0 ; i < links . length ; i ++ ) {
30
+ let link = links [ i ] . getAttribute ( 'href' ) ;
31
+ if ( link . endsWith ( 'test/test_1.css' ) ) {
32
+ done ( ) ;
33
+ return ;
34
+ }
35
+ }
36
+ done ( new Error ( 'css file did not load' ) ) ;
29
37
} ) ;
30
38
} ) ;
31
39
32
- /*
33
- it('width should be equal to 801', function() {
34
- assert.equal(801, window.innerWidth);
35
- });
40
+ it ( 'should not load a stylesheet if it is already loaded' , function ( done ) {
41
+ let link = document . createElement ( 'link' ) ;
42
+ link . type = 'text/css' ;
43
+ link . rel = 'stylesheet' ;
44
+ link . href = window . location . pathname . replace ( 'test/test.html' , '' ) + 'test/test_2.css' ;
45
+ document . head . appendChild ( link ) ;
46
+ link . onload = function ( ) {
47
+ System . import ( '../test/test_2.css' ) . then ( function ( ) {
48
+ done ( new Error ( 'css file loaded while it should not' ) ) ;
49
+ } ) . catch ( function ( e ) {
50
+ done ( ) ;
51
+ } ) ;
52
+ } ;
36
53
37
- it('height should be equal to 501', function() {
38
- assert.equal(501, window.innerHeight);
39
54
} ) ;
40
- */
41
55
42
56
} ) ;
0 commit comments