-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2692 from Azure/dev
Deployment
- Loading branch information
Showing
106 changed files
with
8,592 additions
and
5,365 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
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
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,81 @@ | ||
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; | ||
import { async } from 'q'; | ||
import { BusyStateComponent } from './busy-state.component'; | ||
import { TryNowBusyStateComponent } from '../try-now-busy-state/try-now-busy-state.component'; | ||
import { MockComponent } from 'ng-mocks'; | ||
import { BroadcastService } from '../shared/services/broadcast.service'; | ||
import { MockLogService } from '../test/mocks/log.service.mock'; | ||
import { LogService } from '../shared/services/log.service'; | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { BusyStateScopeManager } from './busy-state-scope-manager'; | ||
|
||
@Component({ | ||
selector: `app-host-component`, | ||
template: `<busy-state name="global"></busy-state>` | ||
}) | ||
class TestBusyStateHostComponent { | ||
@ViewChild(BusyStateComponent) | ||
public busyStateComponent: BusyStateComponent; | ||
|
||
private _busyManager: BusyStateScopeManager; | ||
|
||
constructor(broadcastService: BroadcastService) { | ||
this._busyManager = new BusyStateScopeManager(broadcastService, 'global'); | ||
} | ||
|
||
public setBusy() { | ||
this._busyManager.setBusy(); | ||
} | ||
|
||
public clearBusy() { | ||
this._busyManager.clearBusy(); | ||
} | ||
} | ||
describe('BusyStateComponent', () => { | ||
|
||
let busyStateComponent: BusyStateComponent; | ||
let hostComponent: TestBusyStateHostComponent; | ||
let testFixture: ComponentFixture<TestBusyStateHostComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [BusyStateComponent, TestBusyStateHostComponent, MockComponent(TryNowBusyStateComponent)], | ||
providers: [ | ||
BroadcastService, | ||
{ provide: LogService, useClass: MockLogService } | ||
], | ||
imports: [] | ||
}) | ||
.compileComponents(); | ||
|
||
})); | ||
|
||
beforeEach(() => { | ||
testFixture = TestBed.createComponent(TestBusyStateHostComponent); | ||
hostComponent = testFixture.componentInstance; | ||
busyStateComponent = hostComponent.busyStateComponent; | ||
testFixture.detectChanges(); | ||
}); | ||
|
||
describe('init', () => { | ||
it('component show init', () => { | ||
expect(busyStateComponent).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('public use', () => { | ||
it('set busy broadcast should set busy state to true', fakeAsync(() => { | ||
hostComponent.setBusy(); | ||
tick(100); // wait 100 ms for debounce time | ||
expect(busyStateComponent.busy).toBeTruthy(); | ||
})); | ||
|
||
it('clear busy broadcast should set busy state to false', fakeAsync(() => { | ||
hostComponent.setBusy(); | ||
tick(100); // wait 100 ms for debounce time | ||
hostComponent.clearBusy(); | ||
tick(100); | ||
expect(busyStateComponent.busy).toBeFalsy(); | ||
})); | ||
}); | ||
}); |
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
51 changes: 51 additions & 0 deletions
51
client/src/app/controls/card-info-control/card-info-control.component.spec.ts
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,51 @@ | ||
import { TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { async } from 'q'; | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { CardInfoControlComponent } from './card-info-control.component'; | ||
import { MockDirective } from 'ng-mocks'; | ||
import { LoadImageDirective } from '../load-image/load-image.directive'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
@Component({ | ||
selector: `app-card-info-host-component`, | ||
template: `<app-card-info-control [image]="image" [header]="header" [description]="description" [learnMoreLink]="learnMoreLink"></app-card-info-control>` | ||
}) | ||
class TestCardInfoHostComponent { | ||
@ViewChild(CardInfoControlComponent) | ||
public cardDashbaordComponent: CardInfoControlComponent; | ||
|
||
public image = ''; | ||
public header = ''; | ||
public description = ''; | ||
public learnMoreLink = ''; | ||
} | ||
|
||
describe('CardInfoControl', () => { | ||
let cardInfoComponent: CardInfoControlComponent; | ||
let hostComponent: TestCardInfoHostComponent; | ||
let testFixture: ComponentFixture<TestCardInfoHostComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [CardInfoControlComponent, TestCardInfoHostComponent, MockDirective(LoadImageDirective)], | ||
providers: [ | ||
], | ||
imports: [TranslateModule.forRoot()] | ||
}) | ||
.compileComponents(); | ||
|
||
})); | ||
|
||
beforeEach(() => { | ||
testFixture = TestBed.createComponent(TestCardInfoHostComponent); | ||
hostComponent = testFixture.componentInstance; | ||
cardInfoComponent = hostComponent.cardDashbaordComponent; | ||
testFixture.detectChanges(); | ||
}); | ||
|
||
describe('init', () => { | ||
it('control initiates', () => { | ||
expect(cardInfoComponent).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
client/src/app/controls/command-bar/command-bar.component.spec.ts
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,30 @@ | ||
import { CommandBarComponent } from './command-bar.component'; | ||
import { CommonModule } from '@angular/common'; | ||
import { async } from 'q'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
describe('CommandBar', () => { | ||
let commandBar: CommandBarComponent; | ||
let testFixture: ComponentFixture<CommandBarComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [CommandBarComponent], | ||
imports: [CommonModule] | ||
}) | ||
.compileComponents(); | ||
|
||
})); | ||
|
||
beforeEach(() => { | ||
testFixture = TestBed.createComponent(CommandBarComponent); | ||
commandBar = testFixture.componentInstance; | ||
testFixture.detectChanges(); | ||
}); | ||
|
||
describe('init', () => { | ||
it('should initialize component', () => { | ||
expect(commandBar).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
109 changes: 109 additions & 0 deletions
109
client/src/app/controls/command-bar/command/command.component.spec.ts
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,109 @@ | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { CommandComponent } from './command.component'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { async } from 'q'; | ||
import { MockDirective } from 'ng-mocks'; | ||
import { LoadImageDirective } from '../../load-image/load-image.directive'; | ||
import { By } from '@angular/platform-browser'; | ||
import { KeyCodes } from '../../../shared/models/constants'; | ||
|
||
@Component({ | ||
selector: `app-command-host-component`, | ||
template: `<command [displayText]="displayText" [iconUrl]="iconUrl" [disabled]="disabled" (click)="onClick($event)"></command>` | ||
}) | ||
class TestCommandHostComponent { | ||
@ViewChild(CommandComponent) | ||
public commandComponent: CommandComponent; | ||
|
||
public iconUrl = 'testicon'; | ||
public displayText = 'testtext'; | ||
public disabled = false; | ||
|
||
public clicked = false; | ||
public onClick(event) { | ||
this.clicked = true; | ||
} | ||
} | ||
|
||
describe('CommandControl', () => { | ||
let commandComponent: CommandComponent; | ||
let hostComponent: TestCommandHostComponent; | ||
let testFixture: ComponentFixture<TestCommandHostComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [CommandComponent, TestCommandHostComponent, MockDirective(LoadImageDirective)] | ||
}) | ||
.compileComponents(); | ||
|
||
})); | ||
|
||
beforeEach(() => { | ||
testFixture = TestBed.createComponent(TestCommandHostComponent); | ||
hostComponent = testFixture.componentInstance; | ||
commandComponent = hostComponent.commandComponent; | ||
testFixture.detectChanges(); | ||
}); | ||
|
||
describe('init', () => { | ||
it('should init control', () => { | ||
expect(commandComponent).toBeTruthy(); | ||
}); | ||
it('should have correct text and icon', () => { | ||
expect(commandComponent.displayText).toBe('testtext'); | ||
expect(commandComponent.iconUrl).toBe('testicon'); | ||
}); | ||
|
||
it('should be enabled by default', () => { | ||
expect(commandComponent.disabled).toBeFalsy(); | ||
}); | ||
|
||
}); | ||
|
||
describe('Enabled Behavior', () => { | ||
it('should not have disabled-command class', () => { | ||
const elem = testFixture.debugElement.query(By.css('.disabled-command')); | ||
expect(elem).toBeFalsy(); | ||
}); | ||
|
||
it('click should trigger click event', () => { | ||
const elem = testFixture.debugElement.query(By.css('a')); | ||
elem.nativeElement.click(); | ||
expect(hostComponent.clicked).toBeTruthy(); | ||
}); | ||
|
||
it('enter keypress should trigger click event', () => { | ||
const elem = testFixture.debugElement.query(By.css('a')); | ||
elem.triggerEventHandler('keydown', { | ||
keyCode: KeyCodes.enter | ||
}); | ||
expect(hostComponent.clicked).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('Disabled Behavior', () => { | ||
it('should have disabled-command class', () => { | ||
hostComponent.disabled = true; | ||
testFixture.detectChanges(); | ||
const elem = testFixture.debugElement.query(By.css('.disabled-command')); | ||
expect(elem).toBeTruthy(); | ||
}); | ||
it('click should not trigger click event', () => { | ||
hostComponent.disabled = true; | ||
testFixture.detectChanges(); | ||
const elem = testFixture.debugElement.query(By.css('a')); | ||
elem.nativeElement.click(); | ||
expect(hostComponent.clicked).toBeFalsy(); | ||
}); | ||
|
||
it('enter keypress should trigger click event', () => { | ||
hostComponent.disabled = true; | ||
testFixture.detectChanges(); | ||
const elem = testFixture.debugElement.query(By.css('a')); | ||
elem.triggerEventHandler('keydown', { | ||
keyCode: KeyCodes.enter | ||
}); | ||
expect(hostComponent.clicked).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.