react / wstein / node_modules / jest-cli / src / jasmineTestRunner / __tests__ / JasmineReporter-test.js
80665 views/**1* Copyright (c) 2015, Facebook, Inc. All rights reserved.2*3* This source code is licensed under the BSD-style license found in the4* LICENSE file in the root directory of this source tree. An additional grant5* of patent rights can be found in the PATENTS file in the same directory.6*/7'use strict';89require('mock-modules').autoMockOff();1011describe('JasmineReporter', function() {12// modules13var JasmineReporter;14var colors;1516// other variables17var reporter;1819beforeEach(function() {20JasmineReporter = require('../JasmineReporter');21colors = require('../../lib/colors');2223reporter = new JasmineReporter();24});2526describe('colorization', function() {27function getRunner(actualResult, expectedResult, passed) {28return {29suites: function() {30return [31{32parentSuite: null,33specs: function() {34return [35{36results: function() {37return {38getItems: function() {39return [40{41actual: actualResult,42expected: expectedResult,43matcherName: 'toBe',44passed: function() { return passed; },45trace: {},46type: 'expect',47}48];49},50};51},52},53];54},55suites: function() { return []; },56},57];58},59};60}6162function errorize(str) {63return colors.RED + colors.BOLD + colors.UNDERLINE + str + colors.RESET;64}6566function highlight(str) {67return colors.RED_BG + str + colors.RESET;68}6970pit('colorizes single-line failures using a per-char diff', function() {71var runner = getRunner('foo', 'foobar', false);72reporter.reportRunnerResults(runner);7374return reporter.getResults().then(function(result) {75var message = result.testResults[0].failureMessages[0];76expect(message).toBe(77errorize('Expected:') + ' \'foo\' ' +78errorize('toBe:') + ' \'foo' + highlight('bar') + '\''79);80});81});8283pit('colorizes multi-line failures using a per-line diff', function() {84var runner = getRunner('foo\nbar\nbaz', 'foo\nxxx\nbaz', false);85reporter.reportRunnerResults(runner);8687return reporter.getResults().then(function(result) {88var message = result.testResults[0].failureMessages[0];89expect(message).toBe(90errorize('Expected:') + ' \'foo\n' + highlight('bar\n') + 'baz\' ' +91errorize('toBe:') + ' \'foo\n' + highlight('xxx\n') + 'baz\''92);93});94});95});96});979899