forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increase test coverage (hyperledger-archives#2087)
- Loading branch information
Showing
4 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -75,6 +75,19 @@ describe('ClientService', () => { | |
sandbox.restore(); | ||
}); | ||
|
||
describe('createBusinessNetwork', () => { | ||
it('should pass through and call createNewBusinessDefinition from common', inject([ClientService], (service: ClientService) => { | ||
let name = 'myname'; | ||
let nameversion = '[email protected]'; | ||
let desc = 'my description'; | ||
|
||
let busNetDef = service.createBusinessNetwork(nameversion, desc, null, null); | ||
busNetDef.getName().should.equal(name); | ||
busNetDef.getDescription().should.equal(desc); | ||
busNetDef.getVersion().should.equal('0.0.1'); | ||
})); | ||
}); | ||
|
||
describe('getBusinessNetworkConnection', () => { | ||
it('should get business network connection if set', inject([ClientService], (service: ClientService) => { | ||
service['businessNetworkConnection'] = businessNetworkConMock; | ||
|
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ describe('SampleBusinessNetworkService', () => { | |
let clientMock; | ||
let aclFileMock; | ||
let alertMock; | ||
let businessNetworkMock = sinon.createStubInstance(BusinessNetworkDefinition); | ||
let businessNetworkMock; | ||
let sandbox; | ||
let identityCardMock; | ||
|
||
|
@@ -40,6 +40,7 @@ describe('SampleBusinessNetworkService', () => { | |
clientMock = sinon.createStubInstance(ClientService); | ||
aclFileMock = sinon.createStubInstance(AclFile); | ||
alertMock = sinon.createStubInstance(AlertService); | ||
businessNetworkMock = sinon.createStubInstance(BusinessNetworkDefinition); | ||
|
||
alertMock.busyStatus$ = {next: sinon.stub()}; | ||
|
||
|
@@ -59,6 +60,21 @@ describe('SampleBusinessNetworkService', () => { | |
sandbox.restore(); | ||
}); | ||
|
||
describe('createNewBusinessDefinition', () => { | ||
it('should pass through and call createNewBusinessDefinition from common', inject([SampleBusinessNetworkService], (service: SampleBusinessNetworkService) => { | ||
sinon.restore(businessNetworkMock); | ||
|
||
let name = 'myname'; | ||
let nameversion = '[email protected]'; | ||
let desc = 'my description'; | ||
|
||
let busNetDef = service.createNewBusinessDefinition(nameversion, desc, null, null); | ||
busNetDef.getName().should.equal(name); | ||
busNetDef.getDescription().should.equal(desc); | ||
busNetDef.getVersion().should.equal('0.0.1'); | ||
})); | ||
}); | ||
|
||
describe('getSampleList', () => { | ||
it('should get the list of sample networks', fakeAsync(inject([SampleBusinessNetworkService, XHRBackend], (service: SampleBusinessNetworkService, mockBackend) => { | ||
mockBackend.connections.subscribe((connection) => { | ||
|
@@ -269,6 +285,9 @@ describe('SampleBusinessNetworkService', () => { | |
adminMock.connect.returns(Promise.resolve()); | ||
adminMock.update.returns(Promise.reject('some error')); | ||
|
||
let metaData = {getPackageJson: sinon.stub().returns({})}; | ||
businessNetworkMock.getMetadata.returns(metaData); | ||
|
||
service.updateBusinessNetwork(businessNetworkMock).then(() => { | ||
throw('should not get here'); | ||
}) | ||
|