Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80668 views
1
/**
2
* Copyright 2013 Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
* @emails [email protected] [email protected]
17
*/
18
19
describe('CSSLoader', function() {
20
var CSSLoader = require('../lib/loader/CSSLoader');
21
var path = require('path');
22
var loadResouce = require('../lib/test_helpers/loadResource');
23
24
it('should match package.json paths', function() {
25
var loader = new CSSLoader();
26
expect(loader.matchPath('x.css')).toBe(true);
27
expect(loader.matchPath('a/x.css')).toBe(true);
28
expect(loader.matchPath('a/1.js')).toBe(false);
29
});
30
31
var testData = path.join(__dirname, '..', '__test_data__', 'CSS');
32
33
it('should exptract component name', function() {
34
loadResouce(
35
new CSSLoader(),
36
path.join(testData, 'plain.css'),
37
null,
38
function(err, css) {
39
expect(css.id).toBe('plain-css');
40
expect(css.options).toEqual({ 'no-browser-specific-css' : true });
41
expect(css.requiredCSS).toEqual(['bar']);
42
});
43
});
44
45
it('should parse special attributes', function() {
46
loadResouce(
47
new CSSLoader(),
48
path.join(testData, 'special.css'),
49
null,
50
function(err, css) {
51
expect(css.id).toBe('special-css');
52
expect(css.isNonblocking).toBe(true);
53
expect(css.isNopackage).toBe(true);
54
});
55
});
56
57
it('should exptract css sprites', function() {
58
loadResouce(
59
new CSSLoader({ extractFBSprites: true }),
60
path.join(testData, 'fb-sprite.css'),
61
null,
62
function(err, css) {
63
expect(css.fbSprites).toEqual([
64
'images/dialog/large_halo_top_left.png',
65
'images/dialog/large_halo_top_right.png'
66
]);
67
});
68
});
69
70
it('should exptract network size', function() {
71
loadResouce(
72
new CSSLoader({ networkSize: true }),
73
path.join(testData, 'fb-sprite.css'),
74
null,
75
function(err, css) {
76
expect(css.networkSize > 0).toBe(true);
77
});
78
});
79
});
80
81