-
Notifications
You must be signed in to change notification settings - Fork 127
/
google.protobuf.duration.spec.ts
56 lines (40 loc) · 1.59 KB
/
google.protobuf.duration.spec.ts
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
import {Duration} from "../ts-out/google/protobuf/duration";
import {makeDuration} from "./support/helpers";
describe('google.protobuf.Duration', function () {
describe('toJson()', function () {
it('should encode 3 seconds and 0 nanoseconds in JSON format as "3s"', function () {
let json = Duration.toJson(
makeDuration(3)
);
expect(json).toEqual("3s");
});
it('should encode 3 seconds and 1 nanosecond in JSON format as "3.000000001s"', function () {
let duration = makeDuration(3);
duration.nanos = 1;
let json = Duration.toJson(duration);
expect(json).toEqual("3.000000001s");
});
it('should encode 3 seconds and 1 microsecond in JSON format as "3.000001s"', function () {
let duration = makeDuration(3);
duration.nanos = 1000;
let json = Duration.toJson(duration);
expect(json).toEqual("3.000001s");
});
});
describe('fromJson()', function () {
it('can read "3s"', function () {
let exp = makeDuration(3);
expect(Duration.fromJson('3s')).toEqual(exp);
});
it('can read "3.000000001s"', function () {
let exp = makeDuration(3);
exp.nanos = 1;
expect(Duration.fromJson('3.000000001s')).toEqual(exp);
});
it('can read "3.000001s"', function () {
let exp = makeDuration(3);
exp.nanos = 1000;
expect(Duration.fromJson('3.000001s')).toEqual(exp);
});
});
});