react / wstein / node_modules / jest-cli / node_modules / node-haste / __tests__ / ImageLoader-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('Image', function() {19var ImageLoader = require('../lib/loader/ImageLoader');20var ResourceMap = require('../lib/ResourceMap');21var path = require('path');22var loadResouce = require('../lib/test_helpers/loadResource');23var waitsForCallback = require('../lib/test_helpers/waitsForCallback');2425it('should match package.json paths', function() {26var loader = new ImageLoader();27expect(loader.matchPath('x.png')).toBe(true);28expect(loader.matchPath('x.jpg')).toBe(true);29expect(loader.matchPath('a/x.gif')).toBe(true);30expect(loader.matchPath('a/1.js')).toBe(false);31});3233var testData = path.join(__dirname, '..', '__test_data__', 'Image');3435it('should find the size of the picture', function() {36var loader = new ImageLoader();37loadResouce(38loader,39path.join(testData, 'a.jpg'),40null,41function(errors, resource) {42expect(resource.width).toBe(900);43expect(resource.height).toBe(596);44});45});4647it('should calculate network size when asked', function() {48var loader = new ImageLoader();49loadResouce(50loader,51path.join(testData, 'a.jpg'),52null,53function(errors, r) {54expect(r.networkSize).toBe(127381);55});56});5758it('should return form postProcess with 0 resources', function() {59var loader = new ImageLoader();60var map = new ResourceMap();61waitsForCallback(62function(callback) {63loader.postProcess(map, [], function() {64callback();65});66},67function(messages) {68expect(messages).not.toBe(null);69}70);71});72});737475