• 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 */
15
16function assertContain(actualValue, expect) {
17    let result = false;
18    if (Object.prototype.toString.call(actualValue).indexOf('Array')) {
19        for (let i in actualValue) {
20            if (actualValue[i] == expect[0]) {
21                result = true;
22            }
23        }
24    }
25    let type = Object.prototype.toString.call(actualValue);
26    if (type === '[object String]') {
27        result = actualValue.indexOf(expect[0]) >= 0;
28    }
29    return {
30        pass: result,
31        message: 'expect false, ' + actualValue + ' do not have  ' + expect[0]
32    };
33}
34
35export default assertContain;
36