• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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// @ts-ignore
16import { FormatCommand } from '../../../dist/hdc/hdcclient/FormatCommand.js';
17// @ts-ignore
18import { CmdConstant } from '../../../dist/command/CmdConstant.js';
19
20describe('FormatCommandTest', () => {
21  it('FormatCommandTest_FormatCommand_01', () => {
22    expect(FormatCommand.string2FormatCommand(CmdConstant.CMD_TRACE_FILE_SIZE)).toEqual({
23      bJumpDo: true,
24      cmdFlag: -1,
25      parameters: '',
26    });
27  });
28
29  it('FormatCommandTest_FormatCommand_02', () => {
30    expect(FormatCommand.string2FormatCommand('shell ps')).toEqual({
31      bJumpDo: false,
32      cmdFlag: 1001,
33      parameters: 'ps',
34    });
35  });
36
37  it('FormatCommandTest_FormatCommand_03', () => {
38    expect(FormatCommand.string2FormatCommand('shell')).toEqual({
39      bJumpDo: false,
40      cmdFlag: 2000,
41      parameters: '',
42    });
43  });
44
45  it('FormatCommandTest_FormatCommand_04', () => {
46    expect(FormatCommand.string2FormatCommand('file recv demo')).toEqual({
47      bJumpDo: false,
48      cmdFlag: 3000,
49      parameters: 'demo',
50    });
51  });
52
53  it('FormatCommandTest_FormatCommand_05', () => {
54    expect(FormatCommand.string2FormatCommand('file send demo')).toEqual({
55      bJumpDo: false,
56      cmdFlag: 3000,
57      parameters: 'demo',
58    });
59  });
60
61  it('FormatCommandTest_FormatCommand_06', () => {
62    expect(FormatCommand.string2FormatCommand(CmdConstant.CMD_GET_HIPERF_EVENTS)).toEqual({
63      bJumpDo: true,
64      cmdFlag: -1,
65      parameters: '',
66    });
67  });
68
69  it('FormatCommandTest_FormatCommand_07', () => {
70    expect(FormatCommand.string2FormatCommand('null')).toEqual({
71      bJumpDo: true,
72      cmdFlag: -1,
73      parameters: '',
74    });
75  });
76});
77