• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
15import Core from './core'
16
17const core = Core.getInstance()
18
19const describe = function (desc, func) {
20  if (typeof globalThis !== 'undefined') {
21    return globalThis.describe(desc, func)
22  }
23  return core.describe(desc, func)
24}
25const it = function (desc, filter, func) {
26  if (typeof globalThis !== 'undefined') {
27    return globalThis.it(desc, filter, func)
28  }
29  return core.it(desc, filter, func)
30}
31const beforeEach = function (func) {
32  if (typeof globalThis !== 'undefined') {
33    return globalThis.beforeEach(func)
34  }
35  return core.beforeEach(func)
36}
37const afterEach = function (func) {
38  if (typeof globalThis !== 'undefined') {
39    return globalThis.afterEach(func)
40  }
41  return core.afterEach(func)
42}
43const beforeAll = function (func) {
44  if (typeof globalThis !== 'undefined') {
45    return globalThis.beforeAll(func)
46  }
47  return core.beforeAll(func)
48}
49const afterAll = function (func) {
50  if (typeof globalThis !== 'undefined') {
51    return globalThis.afterAll(func)
52  }
53  return core.afterAll(func)
54}
55const expect = function (actualValue) {
56  if (typeof globalThis !== 'undefined') {
57    return globalThis.expect(actualValue)
58  }
59  return core.expect(actualValue)
60}
61
62export {
63  describe, it, beforeAll, beforeEach, afterEach, afterAll, expect
64}
65