react / wstein / node_modules / jest-cli / node_modules / node-haste / __tests__ / CSSLoader-test.js
80668 views/**1* Copyright 2013 Facebook, Inc.2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*15* @emails [email protected] [email protected]16*/1718describe('CSSLoader', function() {19var CSSLoader = require('../lib/loader/CSSLoader');20var path = require('path');21var loadResouce = require('../lib/test_helpers/loadResource');2223it('should match package.json paths', function() {24var loader = new CSSLoader();25expect(loader.matchPath('x.css')).toBe(true);26expect(loader.matchPath('a/x.css')).toBe(true);27expect(loader.matchPath('a/1.js')).toBe(false);28});2930var testData = path.join(__dirname, '..', '__test_data__', 'CSS');3132it('should exptract component name', function() {33loadResouce(34new CSSLoader(),35path.join(testData, 'plain.css'),36null,37function(err, css) {38expect(css.id).toBe('plain-css');39expect(css.options).toEqual({ 'no-browser-specific-css' : true });40expect(css.requiredCSS).toEqual(['bar']);41});42});4344it('should parse special attributes', function() {45loadResouce(46new CSSLoader(),47path.join(testData, 'special.css'),48null,49function(err, css) {50expect(css.id).toBe('special-css');51expect(css.isNonblocking).toBe(true);52expect(css.isNopackage).toBe(true);53});54});5556it('should exptract css sprites', function() {57loadResouce(58new CSSLoader({ extractFBSprites: true }),59path.join(testData, 'fb-sprite.css'),60null,61function(err, css) {62expect(css.fbSprites).toEqual([63'images/dialog/large_halo_top_left.png',64'images/dialog/large_halo_top_right.png'65]);66});67});6869it('should exptract network size', function() {70loadResouce(71new CSSLoader({ networkSize: true }),72path.join(testData, 'fb-sprite.css'),73null,74function(err, css) {75expect(css.networkSize > 0).toBe(true);76});77});78});798081