config.host populated from connection string Endpoint
This commit is contained in:
Родитель
1d32a9aa1e
Коммит
f9f530659c
|
@ -11,7 +11,7 @@ function EventHubClient(config) {
|
|||
if (!config.host) throw new ArgumentError('Argument config is missing property host');
|
||||
}
|
||||
|
||||
EventHubClient.fromConnectionString = function (connectionString, path) {
|
||||
EventHubClient.fromConnectionString = function (connectionString, path, Type_) {
|
||||
if (!connectionString) {
|
||||
throw new ArgumentError('Missing argument connectionString');
|
||||
}
|
||||
|
@ -27,8 +27,10 @@ EventHubClient.fromConnectionString = function (connectionString, path) {
|
|||
var config = {
|
||||
host: host
|
||||
};
|
||||
|
||||
Type_ = Type_ || EventHubClient;
|
||||
|
||||
return new EventHubClient(config);
|
||||
return new Type_(config);
|
||||
};
|
||||
|
||||
EventHubClient.prototype.open = function () {
|
||||
|
|
|
@ -43,9 +43,16 @@ describe('EventHubClient', function () {
|
|||
};
|
||||
test.should.throw(ArgumentError, 'Connection string doesn\'t have EntityPath, or missing argument path');
|
||||
});
|
||||
|
||||
it('populates config.host from the connection string\'s Endpoint', function () {
|
||||
function TestClient(config) { this.config = config; }
|
||||
var client = EventHubClient.fromConnectionString('Endpoint=sb://abc;EntityPath=xyz', null, TestClient);
|
||||
client.config.should.have.property('host')
|
||||
.that.equals('abc');
|
||||
});
|
||||
|
||||
it('creates an EventHubClient from a connection string', function () {
|
||||
var client = EventHubClient.fromConnectionString('Endpoint=sb://abc;EntityPath=abc');
|
||||
var client = EventHubClient.fromConnectionString('Endpoint=sb://abc;EntityPath=xyz');
|
||||
client.should.be.an.instanceof(EventHubClient);
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче