xref: /test/testfwk/arkxtest/jsunit/src/interface.js (revision 886da342)
1886da342Sopenharmony_ci/*
2886da342Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3886da342Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4886da342Sopenharmony_ci * you may not use this file except in compliance with the License.
5886da342Sopenharmony_ci * You may obtain a copy of the License at
6886da342Sopenharmony_ci *
7886da342Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8886da342Sopenharmony_ci *
9886da342Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10886da342Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11886da342Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12886da342Sopenharmony_ci * See the License for the specific language governing permissions and
13886da342Sopenharmony_ci * limitations under the License.
14886da342Sopenharmony_ci */
15886da342Sopenharmony_ci
16886da342Sopenharmony_ciimport Core from './core';
17886da342Sopenharmony_ci
18886da342Sopenharmony_ciconst core = Core.getInstance();
19886da342Sopenharmony_ci
20886da342Sopenharmony_ciconst describe = function (desc, func) {
21886da342Sopenharmony_ci    return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { };
22886da342Sopenharmony_ci};
23886da342Sopenharmony_ciconst it = function (desc, filter, func) {
24886da342Sopenharmony_ci    return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { };
25886da342Sopenharmony_ci};
26886da342Sopenharmony_ciconst beforeItSpecified = function (itDescs, func) {
27886da342Sopenharmony_ci    return Reflect.has(core, 'beforeItSpecified') ? core.beforeItSpecified(itDescs, func) : (itDescs, func) => { };
28886da342Sopenharmony_ci};
29886da342Sopenharmony_ci
30886da342Sopenharmony_ciconst afterItSpecified = function (itDescs, func) {
31886da342Sopenharmony_ci    return Reflect.has(core, 'afterItSpecified') ? core.afterItSpecified(itDescs, func) : (itDescs, func) => { };
32886da342Sopenharmony_ci};
33886da342Sopenharmony_ciconst beforeEach = function (func) {
34886da342Sopenharmony_ci    return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { };
35886da342Sopenharmony_ci};
36886da342Sopenharmony_ciconst afterEach = function (func) {
37886da342Sopenharmony_ci    return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { };
38886da342Sopenharmony_ci};
39886da342Sopenharmony_ciconst beforeAll = function (func) {
40886da342Sopenharmony_ci    return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { };
41886da342Sopenharmony_ci};
42886da342Sopenharmony_ciconst afterAll = function (func) {
43886da342Sopenharmony_ci    return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { };
44886da342Sopenharmony_ci};
45886da342Sopenharmony_ciconst expect = function (actualValue) {
46886da342Sopenharmony_ci    return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { };
47886da342Sopenharmony_ci};
48886da342Sopenharmony_ci
49886da342Sopenharmony_ciconst xdescribe = function (desc, func) {
50886da342Sopenharmony_ci    return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, null) : (desc, func, reason) => { };
51886da342Sopenharmony_ci};
52886da342Sopenharmony_cixdescribe.reason = (reason) => {
53886da342Sopenharmony_ci    return (desc, func) => {
54886da342Sopenharmony_ci        return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, reason) : (desc, func, reason) => { };
55886da342Sopenharmony_ci    };
56886da342Sopenharmony_ci};
57886da342Sopenharmony_ciconst xit = function (desc, filter, func) {
58886da342Sopenharmony_ci    return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, null) : (desc, filter, func, reason) => { };
59886da342Sopenharmony_ci};
60886da342Sopenharmony_cixit.reason = (reason) => {
61886da342Sopenharmony_ci    return (desc, filter, func) => {
62886da342Sopenharmony_ci        return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, reason) : (desc, filter, func, reason) => { };
63886da342Sopenharmony_ci    };
64886da342Sopenharmony_ci};
65886da342Sopenharmony_ci
66886da342Sopenharmony_ciexport {
67886da342Sopenharmony_ci    describe, it, beforeAll, beforeEach, afterEach, afterAll, expect, beforeItSpecified, afterItSpecified, xdescribe, xit
68886da342Sopenharmony_ci};
69