1/*
2 * Copyright (c) 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
16class ExtendInterface {
17    constructor(mocker) {
18        this.mocker = mocker;
19    }
20
21    stub() {
22        this.params = arguments;
23        return this;
24    }
25
26    stubMockedCall(returnInfo) {
27        this.mocker.stubApply(this, this.params, returnInfo);
28    }
29
30    afterReturn(value) {
31        this.stubMockedCall(function () {
32            return value;
33        });
34    }
35
36    afterReturnNothing() {
37        this.stubMockedCall(function () {
38            return undefined;
39        });
40    }
41
42    afterAction(action) {
43        this.stubMockedCall(action);
44    }
45
46    afterThrow(msg) {
47        this.stubMockedCall(function () {
48            throw msg;
49        });
50    }
51
52    clear() {
53        this.mocker.clear();
54    }
55}
56
57export default ExtendInterface;