Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/composer-playground/.istanbul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ instrumentation:
check:
global:
statements: 98
branches: 91
branches: 93
functions: 96
lines: 98
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ describe('AddConnectionProfileComponent', () => {
});

describe('#addConnectionProfile', () => {

let mockModal;
let mockModalSpy;

beforeEach(inject([NgbActiveModal], (activeModal: NgbActiveModal) => {
Expand All @@ -529,8 +527,7 @@ describe('AddConnectionProfileComponent', () => {
component['addConnectionProfileTimeout'] = TIMEOUT;
}));

it('should deal with the version being 0.6 and a certificate', fakeAsync(() => {
let mockUpdate = sandbox.stub(component, 'updateConnectionProfiles').returns(Promise.resolve());
it('should deal with the version being 0.6 and a certificate', () => {
let EXP = {
default: false,
name: 'New Profile',
Expand All @@ -551,10 +548,34 @@ describe('AddConnectionProfileComponent', () => {
component['version'] = 'v06';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
}));
});

it('should deal with the version being 1', fakeAsync(() => {
let mockUpdate = sandbox.stub(component, 'updateConnectionProfiles').returns(Promise.resolve());
it('should deal with the version being 0.6 and without a certificate', () => {
component['addConnectionProfileCertificate'] = null;

let EXP = {
default: false,
name: 'New Profile',
profile: {
certificate: null,
certificatePath: CERT_PATH,
deployWaitTime: DEPLOY_TIME,
description: DESC,
eventHubURL: EH_URL,
invokeWaitTime: WAIT_TIME,
keyValStore: KEY_VAL_STORE,
membershipServicesURL: MS_URL,
peerURL: PEER_URL,
type: 'hlf'
}
};

component['version'] = 'v06';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
});

it('should deal with the version being 1', () => {
let EXP = {
default: false,
name: 'New Profile',
Expand All @@ -574,15 +595,89 @@ describe('AddConnectionProfileComponent', () => {
component['version'] = 'v1';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
}));
});

it('should deal with the version being 0.6 and with a certificate just whitespace', () => {
component['addConnectionProfileCertificate'] = ' ';

let EXP = {
default: false,
name: 'New Profile',
profile: {
certificate: ' ',
certificatePath: CERT_PATH,
deployWaitTime: DEPLOY_TIME,
description: DESC,
eventHubURL: EH_URL,
invokeWaitTime: WAIT_TIME,
keyValStore: KEY_VAL_STORE,
membershipServicesURL: MS_URL,
peerURL: PEER_URL,
type: 'hlf'
}
};

component['version'] = 'v06';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
});

it('should deal with the version being 0.6 and with a certificate with new line char', () => {
component['addConnectionProfileCertificate'] = 'bob \n';

let EXP = {
default: false,
name: 'New Profile',
profile: {
certificate: 'bob \n',
certificatePath: CERT_PATH,
deployWaitTime: DEPLOY_TIME,
description: DESC,
eventHubURL: EH_URL,
invokeWaitTime: WAIT_TIME,
keyValStore: KEY_VAL_STORE,
membershipServicesURL: MS_URL,
peerURL: PEER_URL,
type: 'hlf'
}
};

component['version'] = 'v06';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
});

it('should deal with the version being 1 with object orderers', () => {
component['addConnectionProfileOrderers'] = [{url: 'http://localhost', cert: 'bob', hostnameOverride: ''}];

let EXP = {
default: false,
name: 'New Profile',
profile: {
ca: CA,
channel: CHANNEL,
timeout: TIMEOUT,
description: DESC,
keyValStore: KEY_VAL_STORE,
mspID: MSPID,
orderers: [{url: 'http://localhost', cert: 'bob', hostnameOverride: ''}],
peers: PEERS,
type: 'hlfv1'
}
};

component['version'] = 'v1';
component.addConnectionProfile();
mockModalSpy.should.have.been.calledWith(EXP);
});

it('should deal with an invalid version', fakeAsync(() => {
it('should deal with an invalid version', () => {
try {
component['version'] = 'badversion';
component.addConnectionProfile();
} catch (e) {
e.message.should.contain('Unknown connection profile version selected');
}
}));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
/* tslint:disable:no-unused-expression */
/* tslint:disable:no-var-requires */
/* tslint:disable:max-classes-per-file */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConfirmComponent } from './confirm.component';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

import * as sinon from 'sinon';
import * as chai from 'chai';

let should = chai.should();

describe('ConfirmComponent', () => {
let component: ConfirmComponent;
let fixture: ComponentFixture<ConfirmComponent>;

let mockActiveModal = sinon.createStubInstance(NgbActiveModal);

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ConfirmComponent],
providers: [NgbActiveModal]
providers: [{provide: NgbActiveModal, useValue: mockActiveModal}]
});
fixture = TestBed.createComponent(ConfirmComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';

/* tslint:disable:no-unused-expression */
/* tslint:disable:no-var-requires */
/* tslint:disable:max-classes-per-file */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ErrorComponent } from './error.component';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

import * as sinon from 'sinon';
import * as chai from 'chai';

let should = chai.should();

describe('ErrorComponent', () => {
// let component: ErrorComponent;
// let fixture: ComponentFixture<ErrorComponent>;
let component: ErrorComponent;
let fixture: ComponentFixture<ErrorComponent>;

// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [ ErrorComponent ]
// })
// .compileComponents();
// }));
let mockActiveModal = sinon.createStubInstance(NgbActiveModal);

// beforeEach(() => {
// fixture = TestBed.createComponent(ErrorComponent);
// component = fixture.componentInstance;
// fixture.detectChanges();
// });
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ErrorComponent],
providers: [{provide: NgbActiveModal, useValue: mockActiveModal}]
});
fixture = TestBed.createComponent(ErrorComponent);
component = fixture.componentInstance;
});

// it('should create', () => {
// expect(component).toBeTruthy();
// });
it('should create', () => {
component.should.be.ok;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
/* tslint:disable:no-unused-expression */
/* tslint:disable:no-var-requires */
/* tslint:disable:max-classes-per-file */
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReplaceComponent } from './replace-confirm.component';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

Expand All @@ -22,7 +20,7 @@ describe('ReplaceComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ReplaceComponent],
providers: [ {provide: NgbActiveModal, useValue: mockActiveModal} ]
providers: [{provide: NgbActiveModal, useValue: mockActiveModal}]
});
fixture = TestBed.createComponent(ReplaceComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* tslint:disable:no-unused-expression */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { Directive, EventEmitter, Output, Input } from '@angular/core';
import { SuccessComponent } from './success.component';
import { AlertService } from '../../services/alert.service';

Expand All @@ -11,7 +10,6 @@ let should = chai.should();
describe('SuccessComponent', () => {
let component: SuccessComponent;
let fixture: ComponentFixture<SuccessComponent>;
let mockAlertConfig;

let messageTimeout = 4000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ describe('ConnectionProfileDataComponent', () => {
(() => {
component.startEditing();
}).should.throw('Unknown connection profile type');

mockOnValueChanged.should.not.have.been.called;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ describe('ConnectionProfileComponent', () => {
component['previousConnectionProfile'] = {name : 'New Connection Profile'};
mockConnectionProfileService.getCurrentConnectionProfile.returns('bob');

component['connectionProfiles'] = [{name : 'bob'}];
component['connectionProfiles'] = [{name : 'fred'}, {name : 'bob'}];
let mockUpdateConnectionProfiles = sinon.stub(component, 'updateConnectionProfiles');
let mockSetCurrentProfile = sinon.stub(component, 'setCurrentProfile');
component.profileUpdated({updated: true, connectionProfile: {name : 'bob'}});
component.profileUpdated(null);

mockUpdateConnectionProfiles.should.not.have.been.called;
mockSetCurrentProfile.should.have.been.calledOnce;
mockSetCurrentProfile.should.have.been.calledWith({name : 'bob'});
});
});
Expand Down