1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import assertNull from './assertNull' 16import assertClose from './assertClose' 17import assertContain from './assertContain' 18import assertLess from './assertLess' 19import assertLarger from './assertLarger' 20import assertFail from './assertFail' 21import assertUndefined from './assertUndefined' 22import assertFalse from './assertFalse' 23import assertInstanceOf from './assertInstanceOf' 24import assertThrowError from './assertThrowError' 25 26class ExpectExtend { 27 constructor (attr) { 28 this.id = attr.id 29 this.matchers = {} 30 } 31 32 extendsMatchers () { 33 this.matchers.assertNull = assertNull 34 this.matchers.assertClose = assertClose 35 this.matchers.assertContain = assertContain 36 this.matchers.assertLess = assertLess 37 this.matchers.assertLarger = assertLarger 38 this.matchers.assertFail = assertFail 39 this.matchers.assertUndefined = assertUndefined 40 this.matchers.assertFalse = assertFalse 41 this.matchers.assertInstanceOf = assertInstanceOf 42 this.matchers.assertThrowError = assertThrowError 43 } 44 45 init (coreContext) { 46 this.coreContext = coreContext 47 this.extendsMatchers() 48 const expectService = this.coreContext.getDefaultService('expect') 49 expectService.addMatchers(this.matchers) 50 } 51 52 apis () { 53 return { 54 'expect': function (actualValue) { 55 return this.coreContext.getDefaultService('expect').expect(actualValue) 56 } 57 } 58 } 59} 60 61export default ExpectExtend 62