Matteo Scandolo | 686547a | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
Matteo Scandolo | a5d03d5 | 2016-07-21 11:35:46 -0700 | [diff] [blame] | 19 | /** |
| 20 | * Collection of helpers for xos tests |
| 21 | */ |
| 22 | |
| 23 | /* exported clickElement */ |
| 24 | /* eslint-disable angular/ng_document_service */ |
| 25 | |
| 26 | const clickElement = function (el){ |
| 27 | const ev = document.createEvent('MouseEvent'); |
| 28 | ev.initMouseEvent( |
| 29 | 'click', |
| 30 | true /* bubble */, true /* cancelable */, |
| 31 | window, null, |
| 32 | 0, 0, 0, 0, /* coordinates */ |
| 33 | false, false, false, false, /* modifier keys */ |
| 34 | 0 /*left*/, null |
| 35 | ); |
| 36 | el.dispatchEvent(ev); |
| 37 | }; |
| 38 | |
| 39 | describe('Matchers inclusion', () => { |
| 40 | beforeEach(function(){ |
| 41 | jasmine.addMatchers({ |
| 42 | toBeInstanceOf: function() { |
| 43 | |
| 44 | return { |
| 45 | compare: (actual, expected) => { |
| 46 | // const actual = actual; |
| 47 | const result = {}; |
| 48 | result.pass = actual instanceof expected.constructor; |
| 49 | |
| 50 | result.message = 'Expected ' + actual + ' to be instance of ' + expected; |
| 51 | |
| 52 | return result; |
| 53 | }, |
| 54 | negativeCompare: (actual, expected) => { |
| 55 | // const actual = actual; |
| 56 | const result = {}; |
| 57 | result.pass = actual instanceof expected.constructor === false; |
| 58 | |
| 59 | result.message = 'Expected ' + actual + ' to be instance of ' + expected; |
| 60 | |
| 61 | return result; |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | }); |
| 66 | }); |
| 67 | }); |
| 68 | console.log('---------------------- Test Helpers Loaded!! -----------------------'); |