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 */ 15 16export const DEFAULT = 0B0000 17 18export const when: when; 19 20export enum TestType { 21 FUNCTION = 0B1, 22 PERFORMANCE = 0B1 << 1, 23 POWER = 0B1 << 2, 24 RELIABILITY = 0B1 << 3, 25 SECURITY = 0B1 << 4, 26 GLOBAL = 0B1 << 5, 27 COMPATIBILITY = 0B1 << 6, 28 USER = 0B1 << 7, 29 STANDARD = 0B1 << 8, 30 SAFETY = 0B1 << 9, 31 RESILIENCE = 0B1 << 10 32} 33 34export enum Size { 35 SMALLTEST = 0B1 << 16, 36 MEDIUMTEST = 0B1 << 17, 37 LARGETEST = 0B1 << 18 38} 39 40export enum Level { 41 LEVEL0 = 0B1 << 24, 42 LEVEL1 = 0B1 << 25, 43 LEVEL2 = 0B1 << 26, 44 LEVEL3 = 0B1 << 27, 45 LEVEL4 = 0B1 << 28 46} 47 48export function describe(testSuiteName: string, callback: Function): void 49 50export function beforeItSpecified(testCaseNames: Array<string> | string, callback: Function): void 51 52export function afterItSpecified(testCaseNames: Array<string> | string, callback: Function): void 53 54export function beforeEach(callback: Function): void 55 56export function afterEach(callback: Function): void 57 58export function beforeAll(callback: Function): void 59 60export function afterAll(callback: Function): void 61 62export function it(testCaseName: string, attribute: (TestType | Size | Level), callback: Function) 63 64export interface Assert { 65 assertClose(expectValue: number, precision: number): void 66 assertContain(expectValue: any): void 67 assertEqual(expectValue: any): void 68 assertFail(): void 69 assertFalse(): void 70 assertTrue(): void 71 assertInstanceOf(expectValue: string): void 72 assertLarger(expectValue: number): void 73 assertLess(expectValue: number): void 74 assertNull(): void 75 assertThrowError(expectValue: string): void 76 assertUndefined(): void 77 assertLargerOrEqual(expectValue: number): void 78 assertLessOrEqual(expectValue: number): void 79 assertNaN(): void 80 assertNegUnlimited(): void 81 assertPosUnlimited(): void 82 not(): Assert; 83 assertDeepEquals(expectValue: any): void 84 assertPromiseIsPending(): void 85 assertPromiseIsRejected(): void 86 assertPromiseIsRejectedWith(expectValue?: any): void 87 assertPromiseIsRejectedWithError(...expectValue): void 88 assertPromiseIsResolved(): void 89 assertPromiseIsResolvedWith(expectValue?: any): void 90} 91 92export function expect(actualValue?: any): Assert 93 94export class ArgumentMatchers { 95 static any; 96 static anyString; 97 static anyBoolean; 98 static anyNumber; 99 static anyObj; 100 static anyFunction; 101 static matchRegexs(Regex: RegExp): void 102} 103 104declare interface when { 105 afterReturn(value: any): any 106 afterReturnNothing(): undefined 107 afterAction(action: any): any 108 afterThrow(e_msg: string): string 109 (argMatchers?: any): when; 110} 111 112export interface VerificationMode { 113 times(count: Number): void 114 never(): void 115 once(): void 116 atLeast(count: Number): void 117 atMost(count: Number): void 118} 119 120export class MockKit { 121 constructor() 122 mockFunc(obj: Object, func: Function): Function 123 mockObject(obj: Object): Object 124 verify(methodName: String, argsArray: Array<any>): VerificationMode 125 ignoreMock(obj: Object, func: Function): void 126 clear(obj: Object): void 127 clearAll(): void 128} 129 130export class SysTestKit { 131 static getDescribeName(): string; 132 static getItName(): string; 133 static getItAttribute(): TestType | Size | Level 134 static actionStart(tag: string): void 135 static actionEnd(tag: string): void 136 static existKeyword(keyword: string, timeout?: number): boolean 137} 138 139export class Hypium { 140 static setData(data: { [key: string]: any }): void 141 static setTimeConfig(systemTime: any) 142 static hypiumTest(abilityDelegator: any, abilityDelegatorArguments: any, testsuite: Function): void 143}