1/* 2 * Copyright (c) 2024 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, 10 * software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 18 19export default function localUnitTest() { 20 describe('localUnitTest', () => { 21 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 22 beforeAll(() => { 23 // Presets an action, which is performed only once before all test cases of the test suite start. 24 // This API supports only one parameter: preset action function. 25 }); 26 beforeEach(() => { 27 // Presets an action, which is performed before each unit test case starts. 28 // The number of execution times is the same as the number of test cases defined by **it**. 29 // This API supports only one parameter: preset action function. 30 }); 31 afterEach(() => { 32 // Presets a clear action, which is performed after each unit test case ends. 33 // The number of execution times is the same as the number of test cases defined by **it**. 34 // This API supports only one parameter: clear action function. 35 }); 36 afterAll(() => { 37 // Presets a clear action, which is performed after all test cases of the test suite end. 38 // This API supports only one parameter: clear action function. 39 }); 40 it('assertContain', 0, () => { 41 // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 42 let a = 'abc'; 43 let b = 'b'; 44 // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 45 expect(a).assertContain(b); 46 expect(a).assertEqual(a); 47 }); 48 }); 49}