Matteo Scandolo | a5d03d5 | 2016-07-21 11:35:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Collection of helpers for xos tests |
| 3 | */ |
| 4 | |
| 5 | /* exported clickElement */ |
| 6 | /* eslint-disable angular/ng_document_service */ |
| 7 | |
| 8 | const clickElement = function (el){ |
| 9 | const ev = document.createEvent('MouseEvent'); |
| 10 | ev.initMouseEvent( |
| 11 | 'click', |
| 12 | true /* bubble */, true /* cancelable */, |
| 13 | window, null, |
| 14 | 0, 0, 0, 0, /* coordinates */ |
| 15 | false, false, false, false, /* modifier keys */ |
| 16 | 0 /*left*/, null |
| 17 | ); |
| 18 | el.dispatchEvent(ev); |
| 19 | }; |
| 20 | |
| 21 | describe('Matchers inclusion', () => { |
| 22 | beforeEach(function(){ |
| 23 | jasmine.addMatchers({ |
| 24 | toBeInstanceOf: function() { |
| 25 | |
| 26 | return { |
| 27 | compare: (actual, expected) => { |
| 28 | // const actual = actual; |
| 29 | const result = {}; |
| 30 | result.pass = actual instanceof expected.constructor; |
| 31 | |
| 32 | result.message = 'Expected ' + actual + ' to be instance of ' + expected; |
| 33 | |
| 34 | return result; |
| 35 | }, |
| 36 | negativeCompare: (actual, expected) => { |
| 37 | // const actual = actual; |
| 38 | const result = {}; |
| 39 | result.pass = actual instanceof expected.constructor === false; |
| 40 | |
| 41 | result.message = 'Expected ' + actual + ' to be instance of ' + expected; |
| 42 | |
| 43 | return result; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | }); |
| 48 | }); |
| 49 | }); |
| 50 | console.log('---------------------- Test Helpers Loaded!! -----------------------'); |