Skip to content

Commit e333b4d

Browse files
committed
unit test
1 parent a94cb0b commit e333b4d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/log_test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { expect } from 'chai';
2+
import { AddOptionsToSearchParams, LogOptions } from './log';
3+
import { URLSearchParams } from 'url';
4+
5+
describe('Log', () => {
6+
describe('AddOptionsToSearchParams', () => {
7+
it('should add options to search params', () => {
8+
const searchParams = new URLSearchParams();
9+
const options: LogOptions = {
10+
follow: true,
11+
limitBytes: 100,
12+
pretty: true,
13+
previous: true,
14+
sinceSeconds: 1,
15+
tailLines: 1,
16+
timestamps: true,
17+
};
18+
AddOptionsToSearchParams(options, searchParams);
19+
expect(searchParams.get('follow')).to.equal('true');
20+
expect(searchParams.get('limitBytes')).to.equal('100');
21+
expect(searchParams.get('pretty')).to.equal('true');
22+
expect(searchParams.get('previous')).to.equal('true');
23+
expect(searchParams.get('sinceSeconds')).to.equal('1');
24+
expect(searchParams.get('tailLines')).to.equal('1');
25+
expect(searchParams.get('timestamps')).to.equal('true');
26+
});
27+
it('should use defaults for', () => {
28+
const searchParams = new URLSearchParams();
29+
const options: LogOptions = {};
30+
AddOptionsToSearchParams(options, searchParams);
31+
expect(searchParams.get('follow')).to.equal('false');
32+
expect(searchParams.get('pretty')).to.equal('false');
33+
expect(searchParams.get('previous')).to.equal('false');
34+
expect(searchParams.get('timestamps')).to.equal('false');
35+
});
36+
})
37+
});

0 commit comments

Comments
 (0)