Skip to content

Commit 138cf33

Browse files
committed
Moved inline test case, fixed typo
1 parent 691478d commit 138cf33

File tree

2 files changed

+69
-52
lines changed

2 files changed

+69
-52
lines changed

test/packets.valid.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,72 @@ module.exports = [
6565
receiveTimestamp: new Date("2017-08-31T06:17:32.066Z"),
6666
transmitTimestamp: new Date("2017-08-31T06:17:32.066Z")
6767
}
68+
},
69+
{
70+
buffer: [
71+
28,
72+
1,
73+
48,
74+
234,
75+
0,
76+
0,
77+
0,
78+
0,
79+
0,
80+
0,
81+
0,
82+
70,
83+
80,
84+
84,
85+
66,
86+
0,
87+
221,
88+
81,
89+
98,
90+
144,
91+
122,
92+
240,
93+
131,
94+
160,
95+
48,
96+
48,
97+
48,
98+
48,
99+
48,
100+
48,
101+
48,
102+
10,
103+
221,
104+
81,
105+
98,
106+
150,
107+
72,
108+
91,
109+
119,
110+
135,
111+
221,
112+
81,
113+
98,
114+
150,
115+
72,
116+
95,
117+
235,
118+
26
119+
],
120+
expected: {
121+
leapIndicator: 0,
122+
version: 3,
123+
mode: 4,
124+
stratum: 1,
125+
poll: 48,
126+
precision: 234,
127+
rootDelay: new Date("1900-01-01T00:00:00.000Z"),
128+
rootDispersion: new Date("1900-01-01T00:00:00.001Z"),
129+
referenceId: "PTB",
130+
referenceTimestamp: new Date("2017-08-30T16:13:04.480Z"),
131+
originTimestamp: new Date("1925-08-15T05:27:12.188Z"),
132+
receiveTimestamp: new Date("2017-08-30T16:13:10.282Z"),
133+
transmitTimestamp: new Date("2017-08-30T16:13:10.282Z")
134+
}
68135
}
69136
];

test/parser.js

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,7 @@ import NtpPacketParser from "../index";
44

55
describe("NTP packet parser", function() {
66
describe("Structure", function() {
7-
const validPacket = new Buffer([
8-
28,
9-
1,
10-
48,
11-
234,
12-
0,
13-
0,
14-
0,
15-
0,
16-
0,
17-
0,
18-
0,
19-
70,
20-
80,
21-
84,
22-
66,
23-
0,
24-
221,
25-
81,
26-
98,
27-
144,
28-
122,
29-
240,
30-
131,
31-
160,
32-
48,
33-
48,
34-
48,
35-
48,
36-
48,
37-
48,
38-
48,
39-
10,
40-
221,
41-
81,
42-
98,
43-
150,
44-
72,
45-
91,
46-
119,
47-
135,
48-
221,
49-
81,
50-
98,
51-
150,
52-
72,
53-
95,
54-
235,
55-
26
56-
]);
7+
const validPacket = require("./packets.valid")[0].buffer;
578

589
it("should parse without errors", function() {
5910
NtpPacketParser.parse(validPacket);
@@ -153,15 +104,14 @@ describe("NTP packet parser", function() {
153104
const validPackets = require("./packets.valid.js");
154105
validPackets.forEach(function(packet) {
155106
describe("Parsing", function() {
156-
// generisch Buffer und Struct ableichen
157107
const struct = NtpPacketParser.parse(packet.buffer);
158108

159109
for (let key in packet.expected) {
160110
if (!packet.expected.hasOwnProperty(key)) {
161111
continue;
162112
}
163113

164-
it("should have the propety " + key, function() {
114+
it("should have the property " + key, function() {
165115
assert.ok(key in struct);
166116
});
167117

0 commit comments

Comments
 (0)