Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d22f98

Browse files
committed
add tests for decodeTimestampToTimeSpec
1 parent 90bd727 commit 3d22f98

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

‎test/codec-timestamp.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import assert from "assert";
22
import util from "util";
3-
import { encode, decode, encodeDateToTimeSpec, decodeTimestampExtension } from "../src";
3+
import {
4+
encode,
5+
decode,
6+
encodeDateToTimeSpec,
7+
decodeTimestampExtension,
8+
decodeTimestampToTimeSpec,
9+
encodeTimestampExtension,
10+
} from "../src";
411

512
const TIME = 1556636810389;
613

@@ -35,6 +42,14 @@ describe("codec: timestamp 32/64/96", () => {
3542
});
3643
});
3744

45+
context("encodeDateToTimeSpec", () => {
46+
it("decodes timestamp-ext binary to TimeSpec", () => {
47+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48+
const encoded = encodeTimestampExtension(new Date(42000))!;
49+
assert.deepStrictEqual(decodeTimestampToTimeSpec(encoded), { sec: 42, nsec: 0 });
50+
});
51+
});
52+
3853
context("decodeTimestampExtension", () => {
3954
context("for broken data", () => {
4055
it("throws errors", () => {

‎test/readme.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import { deepStrictEqual } from "assert";
2-
import {
3-
encode,
4-
decode,
5-
ExtensionCodec,
6-
EXT_TIMESTAMP,
7-
encodeTimeSpecToTimestamp,
8-
decodeTimestampToTimeSpec,
9-
} from "../src";
2+
import { encode, decode } from "../src";
103

114
describe("README", () => {
125
context("#synopsis", () => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /