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, 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 16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 17 18export default function localUnitTest() { 19 describe('localUnitTest', () => { 20 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 21 beforeAll(() => { 22 // Presets an action, which is performed only once before all test cases of the test suite start. 23 // This API supports only one parameter: preset action function. 24 }); 25 beforeEach(() => { 26 // Presets an action, which is performed before each unit test case starts. 27 // The number of execution times is the same as the number of test cases defined by **it**. 28 // This API supports only one parameter: preset action function. 29 }); 30 afterEach(() => { 31 // Presets a clear action, which is performed after each unit test case ends. 32 // The number of execution times is the same as the number of test cases defined by **it**. 33 // This API supports only one parameter: clear action function. 34 }); 35 afterAll(() => { 36 // Presets a clear action, which is performed after all test cases of the test suite end. 37 // This API supports only one parameter: clear action function. 38 }); 39 it('assertContain', 0, () => { 40 // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 41 let a = 'abc'; 42 let b = 'b'; 43 // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 44 expect(a).assertContain(b); 45 expect(a).assertEqual(a); 46 }); 47 }); 48}