-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bus): implement HTTP command dispatcher (#20)
closes #19
- Loading branch information
1 parent
e52ced2
commit ec3b30d
Showing
16 changed files
with
616 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,6 @@ | |
"bus" | ||
], | ||
"peerDependencies": { | ||
"@secbox/core": "^0.3.0" | ||
"@secbox/core": ">=0.3.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { HttpCommand, HttpOptions } from './HttpCommand'; | ||
import { Method } from 'axios'; | ||
|
||
describe('HttpCommand', () => { | ||
describe('constructor', () => { | ||
it('should set default values to props', () => { | ||
// arrange | ||
const options: HttpOptions<string> = { | ||
payload: 'Test', | ||
url: '/api/test', | ||
method: 'GET' | ||
}; | ||
|
||
// act | ||
const command = new HttpCommand(options); | ||
|
||
// assert | ||
expect(command).toMatchObject({ | ||
ttl: 10000, | ||
expectReply: true, | ||
type: 'HttpCommand', | ||
createdAt: expect.any(Date), | ||
correlationId: expect.any(String) | ||
}); | ||
}); | ||
|
||
it('should set GET to method by default', () => { | ||
// arrange | ||
const options: HttpOptions<string> = { | ||
payload: 'Test', | ||
url: '/api/test' | ||
}; | ||
|
||
// act | ||
const command = new HttpCommand(options); | ||
|
||
// assert | ||
expect(command).toMatchObject({ | ||
method: 'GET' | ||
}); | ||
}); | ||
|
||
it('should raise an exception if method is not string', () => { | ||
// arrange | ||
const options = { | ||
payload: 'Test', | ||
url: '/api/test', | ||
method: 0 as unknown as Method | ||
}; | ||
|
||
// act / assert | ||
expect(() => new HttpCommand(options)).toThrow('`method` must be string'); | ||
}); | ||
|
||
it('should raise an exception if url is not string', () => { | ||
// arrange | ||
const options = { payload: 'Test', url: 0 as unknown as string }; | ||
|
||
// assert | ||
expect(() => new HttpCommand(options)).toThrow('`url` must be string'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.