Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit a298c26

Browse files
committed
Added test for style already loaded using another way other that SystemJS
1 parent 793bd71 commit a298c26

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed
File renamed without changes.

test/test_2.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test {
2+
color: #ddd;
3+
}

test/tests.js

+25-11
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,38 @@ describe('CSS', function() {
1919

2020
this.timeout(5000);
2121

22-
it('should have systemjs loaded', function(){
22+
it('should load systemjs', function(){
2323
assert.ok(typeof window.System === 'object');
2424
});
2525

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'));
2937
});
3038
});
3139

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+
};
3653

37-
it('height should be equal to 501', function() {
38-
assert.equal(501, window.innerHeight);
3954
});
40-
*/
4155

4256
});

0 commit comments

Comments
 (0)