blob: 625124e2e8108b031e9d2a9e55d6e96d00434adb [file] [log] [blame]
Matteo Scandolo686547a2017-08-08 13:05:25 -07001
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 Scandoloa5d03d52016-07-21 11:35:46 -070019/**
20 * Collection of helpers for xos tests
21 */
22
23/* exported clickElement */
24/* eslint-disable angular/ng_document_service */
25
26const 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
39describe('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});
68console.log('---------------------- Test Helpers Loaded!! -----------------------');