Skip to content

Commit

Permalink
test: add missing test cases
Browse files Browse the repository at this point in the history
Co-authored-by: imdudu1 <[email protected]>
  • Loading branch information
jbl428 and imdudu1 committed Apr 30, 2023
1 parent ad973ba commit a93fdb2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/builders/request-form.builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ describe('RequestFormBuilder', () => {
expect([...actual.entries()]).toEqual([['keyword', 'search']]);
});

test('should ignore null value in args', () => {
// given
const builder = new RequestFormBuilder(0, 'keyword');
const args = [null];

// when
const actual = builder.build(args);

// then
expect([...actual.entries()]).toEqual([['keyword', '']]);
});

test('should build form data with explicit key and default', () => {
// given
const builder = new RequestFormBuilder(0, 'keyword', 'search');
Expand Down
15 changes: 15 additions & 0 deletions lib/builders/request-header.builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ describe('RequestHeaderBuilder', () => {
expect(actual).toEqual({ keyword: 'search' });
});

test('should ignore null value in args', () => {
// given
const builder = new RequestHeaderBuilder({
parameterIndex: 0,
key: 'keyword',
});
const args = [null];

// when
const actual = builder.build(args);

// then
expect(actual).toEqual({ keyword: '' });
});

test('should build header with explicit key and default', () => {
// given
const builder = new RequestHeaderBuilder({
Expand Down
12 changes: 12 additions & 0 deletions lib/builders/request-param.builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ describe('RequestParamBuilder', () => {
expect(actual).toBe('?keyword=search');
});

test('should ignore null value in args', () => {
// given
const builder = new RequestParamBuilder(0, 'keyword');
const args = [null];

// when
const actual = builder.build(args);

// then
expect(actual).toBe('?keyword=');
});

test('should build query string with explicit key and default', () => {
// given
const builder = new RequestParamBuilder(0, 'keyword', 'default');
Expand Down

0 comments on commit a93fdb2

Please sign in to comment.