@@ -5,8 +5,8 @@ import { URLSearchParams } from 'url';
5
5
describe ( 'Log' , ( ) => {
6
6
describe ( 'AddOptionsToSearchParams' , ( ) => {
7
7
it ( 'should add options to search params' , ( ) => {
8
- const searchParams = new URLSearchParams ( ) ;
9
- const options : LogOptions = {
8
+ let searchParams = new URLSearchParams ( ) ;
9
+ let options : LogOptions = {
10
10
follow : true ,
11
11
limitBytes : 100 ,
12
12
pretty : true ,
@@ -23,6 +23,12 @@ describe('Log', () => {
23
23
expect ( searchParams . get ( 'sinceSeconds' ) ) . to . equal ( '1' ) ;
24
24
expect ( searchParams . get ( 'tailLines' ) ) . to . equal ( '1' ) ;
25
25
expect ( searchParams . get ( 'timestamps' ) ) . to . equal ( 'true' ) ;
26
+
27
+ const sinceTime = new Date ( ) . toISOString ( ) ;
28
+ searchParams = new URLSearchParams ( ) ;
29
+ options = { sinceTime } ;
30
+ AddOptionsToSearchParams ( options , searchParams ) ;
31
+ expect ( searchParams . get ( 'sinceTime' ) ) . to . equal ( sinceTime ) ;
26
32
} ) ;
27
33
it ( 'should use defaults for' , ( ) => {
28
34
const searchParams = new URLSearchParams ( ) ;
@@ -33,5 +39,16 @@ describe('Log', () => {
33
39
expect ( searchParams . get ( 'previous' ) ) . to . equal ( 'false' ) ;
34
40
expect ( searchParams . get ( 'timestamps' ) ) . to . equal ( 'false' ) ;
35
41
} ) ;
42
+ it ( 'sinceTime and sinceSeconds cannot be used together' , ( ) => {
43
+ const searchParams = new URLSearchParams ( ) ;
44
+ const sinceTime = new Date ( ) . toISOString ( ) ;
45
+ const options : LogOptions = {
46
+ sinceSeconds : 1 ,
47
+ sinceTime,
48
+ } ;
49
+ expect ( ( ) => {
50
+ AddOptionsToSearchParams ( options , searchParams ) ;
51
+ } ) . to . throw ( 'at most one of sinceTime or sinceSeconds may be specified' ) ;
52
+ } ) ;
36
53
} ) ;
37
54
} ) ;
0 commit comments