1/* 2 * Copyright (c) 2021-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 Core from './core'; 17 18const core = Core.getInstance(); 19 20const describe = function (desc, func) { 21 return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; 22}; 23const it = function (desc, filter, func) { 24 return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; 25}; 26const beforeItSpecified = function (itDescs, func) { 27 return Reflect.has(core, 'beforeItSpecified') ? core.beforeItSpecified(itDescs, func) : (itDescs, func) => { }; 28}; 29 30const afterItSpecified = function (itDescs, func) { 31 return Reflect.has(core, 'afterItSpecified') ? core.afterItSpecified(itDescs, func) : (itDescs, func) => { }; 32}; 33const beforeEach = function (func) { 34 return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; 35}; 36const afterEach = function (func) { 37 return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; 38}; 39const beforeAll = function (func) { 40 return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; 41}; 42const afterAll = function (func) { 43 return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; 44}; 45const expect = function (actualValue) { 46 return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; 47}; 48 49const xdescribe = function (desc, func) { 50 return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, null) : (desc, func, reason) => { }; 51}; 52xdescribe.reason = (reason) => { 53 return (desc, func) => { 54 return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, reason) : (desc, func, reason) => { }; 55 }; 56}; 57const xit = function (desc, filter, func) { 58 return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, null) : (desc, filter, func, reason) => { }; 59}; 60xit.reason = (reason) => { 61 return (desc, filter, func) => { 62 return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, reason) : (desc, filter, func, reason) => { }; 63 }; 64}; 65 66export { 67 describe, it, beforeAll, beforeEach, afterEach, afterAll, expect, beforeItSpecified, afterItSpecified, xdescribe, xit 68}; 69