1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ɵgetDOM as getDOM } from '@angular/common';
|
---|
9 | import { ɵglobal as global } from '@angular/core';
|
---|
10 | import { ComponentFixture } from '@angular/core/testing';
|
---|
11 | import { By } from '@angular/platform-browser';
|
---|
12 | import { childNodesAsList, hasClass, hasStyle, isCommentNode } from './browser_util';
|
---|
13 | const _global = (typeof window === 'undefined' ? global : window);
|
---|
14 | /**
|
---|
15 | * Jasmine matching function with Angular matchers mixed in.
|
---|
16 | *
|
---|
17 | * ## Example
|
---|
18 | *
|
---|
19 | * {@example testing/ts/matchers.ts region='toHaveText'}
|
---|
20 | */
|
---|
21 | export const expect = _global.expect;
|
---|
22 | // Some Map polyfills don't polyfill Map.toString correctly, which
|
---|
23 | // gives us bad error messages in tests.
|
---|
24 | // The only way to do this in Jasmine is to monkey patch a method
|
---|
25 | // to the object :-(
|
---|
26 | Map.prototype['jasmineToString'] = function () {
|
---|
27 | const m = this;
|
---|
28 | if (!m) {
|
---|
29 | return '' + m;
|
---|
30 | }
|
---|
31 | const res = [];
|
---|
32 | m.forEach((v, k) => {
|
---|
33 | res.push(`${String(k)}:${String(v)}`);
|
---|
34 | });
|
---|
35 | return `{ ${res.join(',')} }`;
|
---|
36 | };
|
---|
37 | _global.beforeEach(function () {
|
---|
38 | // Custom handler for Map as we use Jasmine 2.4, and support for maps is not
|
---|
39 | // added until Jasmine 2.6.
|
---|
40 | jasmine.addCustomEqualityTester(function compareMap(actual, expected) {
|
---|
41 | if (actual instanceof Map) {
|
---|
42 | let pass = actual.size === expected.size;
|
---|
43 | if (pass) {
|
---|
44 | actual.forEach((v, k) => {
|
---|
45 | pass = pass && jasmine.matchersUtil.equals(v, expected.get(k));
|
---|
46 | });
|
---|
47 | }
|
---|
48 | return pass;
|
---|
49 | }
|
---|
50 | else {
|
---|
51 | // TODO(misko): we should change the return, but jasmine.d.ts is not null safe
|
---|
52 | return undefined;
|
---|
53 | }
|
---|
54 | });
|
---|
55 | jasmine.addMatchers({
|
---|
56 | toBePromise: function () {
|
---|
57 | return {
|
---|
58 | compare: function (actual) {
|
---|
59 | const pass = typeof actual === 'object' && typeof actual.then === 'function';
|
---|
60 | return {
|
---|
61 | pass: pass,
|
---|
62 | get message() {
|
---|
63 | return 'Expected ' + actual + ' to be a promise';
|
---|
64 | }
|
---|
65 | };
|
---|
66 | }
|
---|
67 | };
|
---|
68 | },
|
---|
69 | toBeAnInstanceOf: function () {
|
---|
70 | return {
|
---|
71 | compare: function (actual, expectedClass) {
|
---|
72 | const pass = typeof actual === 'object' && actual instanceof expectedClass;
|
---|
73 | return {
|
---|
74 | pass: pass,
|
---|
75 | get message() {
|
---|
76 | return 'Expected ' + actual + ' to be an instance of ' + expectedClass;
|
---|
77 | }
|
---|
78 | };
|
---|
79 | }
|
---|
80 | };
|
---|
81 | },
|
---|
82 | toHaveText: function () {
|
---|
83 | return {
|
---|
84 | compare: function (actual, expectedText) {
|
---|
85 | const actualText = elementText(actual);
|
---|
86 | return {
|
---|
87 | pass: actualText == expectedText,
|
---|
88 | get message() {
|
---|
89 | return 'Expected ' + actualText + ' to be equal to ' + expectedText;
|
---|
90 | }
|
---|
91 | };
|
---|
92 | }
|
---|
93 | };
|
---|
94 | },
|
---|
95 | toHaveCssClass: function () {
|
---|
96 | return { compare: buildError(false), negativeCompare: buildError(true) };
|
---|
97 | function buildError(isNot) {
|
---|
98 | return function (actual, className) {
|
---|
99 | return {
|
---|
100 | pass: hasClass(actual, className) == !isNot,
|
---|
101 | get message() {
|
---|
102 | return `Expected ${actual.outerHTML} ${isNot ? 'not ' : ''}to contain the CSS class "${className}"`;
|
---|
103 | }
|
---|
104 | };
|
---|
105 | };
|
---|
106 | }
|
---|
107 | },
|
---|
108 | toHaveCssStyle: function () {
|
---|
109 | return {
|
---|
110 | compare: function (actual, styles) {
|
---|
111 | let allPassed;
|
---|
112 | if (typeof styles === 'string') {
|
---|
113 | allPassed = hasStyle(actual, styles);
|
---|
114 | }
|
---|
115 | else {
|
---|
116 | allPassed = Object.keys(styles).length !== 0;
|
---|
117 | Object.keys(styles).forEach(prop => {
|
---|
118 | allPassed = allPassed && hasStyle(actual, prop, styles[prop]);
|
---|
119 | });
|
---|
120 | }
|
---|
121 | return {
|
---|
122 | pass: allPassed,
|
---|
123 | get message() {
|
---|
124 | const expectedValueStr = typeof styles === 'string' ? styles : JSON.stringify(styles);
|
---|
125 | return `Expected ${actual.outerHTML} ${!allPassed ? ' ' : 'not '}to contain the
|
---|
126 | CSS ${typeof styles === 'string' ? 'property' : 'styles'} "${expectedValueStr}"`;
|
---|
127 | }
|
---|
128 | };
|
---|
129 | }
|
---|
130 | };
|
---|
131 | },
|
---|
132 | toContainError: function () {
|
---|
133 | return {
|
---|
134 | compare: function (actual, expectedText) {
|
---|
135 | const errorMessage = actual.toString();
|
---|
136 | return {
|
---|
137 | pass: errorMessage.indexOf(expectedText) > -1,
|
---|
138 | get message() {
|
---|
139 | return 'Expected ' + errorMessage + ' to contain ' + expectedText;
|
---|
140 | }
|
---|
141 | };
|
---|
142 | }
|
---|
143 | };
|
---|
144 | },
|
---|
145 | toImplement: function () {
|
---|
146 | return {
|
---|
147 | compare: function (actualObject, expectedInterface) {
|
---|
148 | const intProps = Object.keys(expectedInterface.prototype);
|
---|
149 | const missedMethods = [];
|
---|
150 | intProps.forEach((k) => {
|
---|
151 | if (!actualObject.constructor.prototype[k])
|
---|
152 | missedMethods.push(k);
|
---|
153 | });
|
---|
154 | return {
|
---|
155 | pass: missedMethods.length == 0,
|
---|
156 | get message() {
|
---|
157 | return 'Expected ' + actualObject +
|
---|
158 | ' to have the following methods: ' + missedMethods.join(', ');
|
---|
159 | }
|
---|
160 | };
|
---|
161 | }
|
---|
162 | };
|
---|
163 | },
|
---|
164 | toContainComponent: function () {
|
---|
165 | return {
|
---|
166 | compare: function (actualFixture, expectedComponentType) {
|
---|
167 | const failOutput = arguments[2];
|
---|
168 | const msgFn = (msg) => [msg, failOutput].filter(Boolean).join(', ');
|
---|
169 | // verify correct actual type
|
---|
170 | if (!(actualFixture instanceof ComponentFixture)) {
|
---|
171 | return {
|
---|
172 | pass: false,
|
---|
173 | message: msgFn(`Expected actual to be of type \'ComponentFixture\' [actual=${actualFixture.constructor.name}]`)
|
---|
174 | };
|
---|
175 | }
|
---|
176 | const found = !!actualFixture.debugElement.query(By.directive(expectedComponentType));
|
---|
177 | return found ?
|
---|
178 | { pass: true } :
|
---|
179 | { pass: false, message: msgFn(`Expected ${expectedComponentType.name} to show`) };
|
---|
180 | }
|
---|
181 | };
|
---|
182 | }
|
---|
183 | });
|
---|
184 | });
|
---|
185 | function elementText(n) {
|
---|
186 | const hasNodes = (n) => {
|
---|
187 | const children = n.childNodes;
|
---|
188 | return children && children.length > 0;
|
---|
189 | };
|
---|
190 | if (n instanceof Array) {
|
---|
191 | return n.map(elementText).join('');
|
---|
192 | }
|
---|
193 | if (isCommentNode(n)) {
|
---|
194 | return '';
|
---|
195 | }
|
---|
196 | if (getDOM().isElementNode(n)) {
|
---|
197 | const tagName = n.tagName;
|
---|
198 | if (tagName === 'CONTENT') {
|
---|
199 | return elementText(Array.prototype.slice.apply(n.getDistributedNodes()));
|
---|
200 | }
|
---|
201 | else if (tagName === 'SLOT') {
|
---|
202 | return elementText(Array.prototype.slice.apply(n.assignedNodes()));
|
---|
203 | }
|
---|
204 | }
|
---|
205 | if (hasShadowRoot(n)) {
|
---|
206 | return elementText(childNodesAsList(n.shadowRoot));
|
---|
207 | }
|
---|
208 | if (hasNodes(n)) {
|
---|
209 | return elementText(childNodesAsList(n));
|
---|
210 | }
|
---|
211 | return n.textContent;
|
---|
212 | }
|
---|
213 | function hasShadowRoot(node) {
|
---|
214 | return node.shadowRoot != null && node instanceof HTMLElement;
|
---|
215 | }
|
---|
216 | //# sourceMappingURL=data:application/json;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G4gICAgICAgICAgICAgICAgICAgICAgQ1NTICR7dHlwZW9mIHN0eWxlcyA9PT0gJ3N0cmluZycgPyAncHJvcGVydHknIDogJ3N0eWxlcyd9IFwiJHtcbiAgICAgICAgICAgICAgICAgIGV4cGVjdGVkVmFsdWVTdHJ9XCJgO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICAgIH07XG4gICAgfSxcblxuICAgIHRvQ29udGFpbkVycm9yOiBmdW5jdGlvbigpIHtcbiAgICAgIHJldHVybiB7XG4gICAgICAgIGNvbXBhcmU6IGZ1bmN0aW9uKGFjdHVhbDogYW55LCBleHBlY3RlZFRleHQ6IGFueSkge1xuICAgICAgICAgIGNvbnN0IGVycm9yTWVzc2FnZSA9IGFjdHVhbC50b1N0cmluZygpO1xuICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBwYXNzOiBlcnJvck1lc3NhZ2UuaW5kZXhPZihleHBlY3RlZFRleHQpID4gLTEsXG4gICAgICAgICAgICBnZXQgbWVzc2FnZSgpIHtcbiAgICAgICAgICAgICAgcmV0dXJuICdFeHBlY3RlZCAnICsgZXJyb3JNZXNzYWdlICsgJyB0byBjb250YWluICcgKyBleHBlY3RlZFRleHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgfTtcbiAgICB9LFxuXG4gICAgdG9JbXBsZW1lbnQ6IGZ1bmN0aW9uKCkge1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgY29tcGFyZTogZnVuY3Rpb24oYWN0dWFsT2JqZWN0OiBhbnksIGV4cGVjdGVkSW50ZXJmYWNlOiBhbnkpIHtcbiAgICAgICAgICBjb25zdCBpbnRQcm9wcyA9IE9iamVjdC5rZXlzKGV4cGVjdGVkSW50ZXJmYWNlLnByb3RvdHlwZSk7XG5cbiAgICAgICAgICBjb25zdCBtaXNzZWRNZXRob2RzOiBhbnlbXSA9IFtdO1xuICAgICAgICAgIGludFByb3Bz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