• 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
16// @ts-ignore
17import {Serialize} from "../../../dist/hdc/common/Serialize.js"
18
19describe('Serialize Test', ()=> {
20    it('Serialize Test01', function () {
21        let banne = {
22            banner:1,
23            authType:1,
24            sessionId:1,
25            connectKey:1,
26            buf:'',
27        }
28        expect(Serialize.serializeSessionHandShake(banne)).not.toBeUndefined()
29
30    })
31    it('Serialize Test02', function () {
32        let payloadProtect = {
33            channelId:1,
34            commandFlag:1,
35            checkSum:1,
36            vCode:1,
37        }
38        expect(Serialize.serializePayloadProtect(payloadProtect)).not.toBeUndefined()
39
40    })
41    it('Serialize Test03', function () {
42        let transferConfig = {
43            fileSize:1,
44            atime:1,
45            mtime:1,
46            options:1,
47            path:1,
48            optionalName:1,
49            updateIfNew:1,
50            compressType:1,
51            holdTimestamp:1,
52            functionName:1,
53            clientCwd:1,
54            reserve1:1,
55            reserve2:1,
56        }
57        expect(Serialize.serializeTransferConfig(transferConfig)).not.toBeUndefined()
58    })
59    it('Serialize Test04', function () {
60        let transferPayload = {
61            index:1,
62            compressType:1,
63            compressSize:1,
64            uncompressSize:1,
65        }
66        expect(Serialize.serializeTransferPayload(transferPayload)).not.toBeUndefined()
67    })
68    it('Serialize Test06', function () {
69        let data ={
70            buffer:1,
71        }
72        // @ts-ignore
73        let uint8Array = new Uint8Array(data);
74        let dataBuffer = uint8Array.buffer;
75        expect(Serialize.parseTransferConfig(data)).not.toBeUndefined()
76    })
77    it('Serialize Test05', function () {
78        let tagKey = 1;
79        expect(Serialize.readTagWireType(tagKey)).not.toBeUndefined()
80    })
81    it('Serialize Test07', function () {
82        let data ={
83            buffer:1,
84        }
85        // @ts-ignore
86        let uint8Array = new Uint8Array(data);
87        let dataBuffer = uint8Array.buffer;
88        expect(Serialize.parsePayloadProtect(data)).not.toBeUndefined()
89    })
90
91    it('Serialize Test08', function () {
92        expect(Serialize.writeVarIntU64(100_000_000)).not.toBeUndefined();
93    });
94
95    it('Serialize Test09', function () {
96        let data ={
97            buffer:1,
98        }
99        // @ts-ignore
100        let uint8Array = new Uint8Array(data);
101        expect(Serialize.parseString(uint8Array,1)).not.toBeUndefined();
102    });
103
104    it('Serialize Test10', function () {
105        let data ={
106            buffer:1,
107        }
108        // @ts-ignore
109        let uint8Array = new Uint8Array(data);
110        expect(Serialize.parseHandshake(uint8Array)).toEqual({"_authType": -1, "_banner": "", "_buf": "", "_connectKey": "", "_sessionId": -1, "_version": ""});
111    });
112
113    it('Serialize Test11', function () {
114        expect(Serialize.writeVarIntU32(100_000_000)).not.toBeUndefined();
115    })
116})