forked from nirui/sshwifty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader_test.js
56 lines (44 loc) · 1.71 KB
/
header_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Sshwifty - A Web SSH client
//
// Copyright (C) 2019-2023 Ni Rui <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import assert from "assert";
import * as header from "./header.js";
describe("Header", () => {
it("Header", () => {
let h = new header.Header(header.ECHO);
h.set(63);
let n = new header.Header(h.value());
assert.strictEqual(h.type(), n.type());
assert.strictEqual(h.data(), n.data());
assert.strictEqual(n.type(), header.CONTROL);
assert.strictEqual(n.data(), 63);
});
it("Stream", () => {
let h = new header.Stream(0, 0);
h.set(header.STREAM_MAX_MARKER, header.STREAM_MAX_LENGTH);
assert.strictEqual(h.marker(), header.STREAM_MAX_MARKER);
assert.strictEqual(h.length(), header.STREAM_MAX_LENGTH);
assert.strictEqual(h.headerByte1, 0xff);
assert.strictEqual(h.headerByte2, 0xff);
});
it("InitialStream", () => {
let h = new header.InitialStream(0, 0);
h.set(15, 128, true);
assert.strictEqual(h.command(), 15);
assert.strictEqual(h.data(), 128);
assert.strictEqual(h.success(), true);
});
});