-
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.
- Loading branch information
Showing
17 changed files
with
497 additions
and
70 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
ui/src/app/metadata/provider/component/provider-wizard-summary.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,94 @@ | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, Store, combineReducers } from '@ngrx/store'; | ||
|
||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { ProviderWizardSummaryComponent } from './provider-wizard-summary.component'; | ||
import * as fromRoot from '../reducer'; | ||
import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-schema-form'; | ||
import * as fromWizard from '../../../wizard/reducer'; | ||
import { Wizard } from '../../../wizard/model'; | ||
import { MetadataProvider } from '../../domain/model'; | ||
import { SummaryPropertyComponent } from './summary-property.component'; | ||
import { SCHEMA } from '../../../../testing/form-schema.stub'; | ||
import { MetadataProviderWizard } from '../model'; | ||
|
||
@Component({ | ||
template: ` | ||
<provider-wizard-summary [summary]="summary"></provider-wizard-summary> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(ProviderWizardSummaryComponent) | ||
public componentUnderTest: ProviderWizardSummaryComponent; | ||
|
||
private _summary; | ||
|
||
get summary(): { definition: Wizard<MetadataProvider>, schema: { [id: string]: any }, model: any } { | ||
return this._summary; | ||
} | ||
|
||
set summary(summary: { definition: Wizard<MetadataProvider>, schema: { [id: string]: any }, model: any }) { | ||
this._summary = summary; | ||
} | ||
} | ||
|
||
describe('Provider Wizard Summary Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: ProviderWizardSummaryComponent; | ||
let store: Store<fromRoot.State>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule.forRoot(), | ||
RouterTestingModule, | ||
SchemaFormModule.forRoot(), | ||
StoreModule.forRoot({ | ||
provider: combineReducers(fromRoot.reducers), | ||
wizard: combineReducers(fromWizard.reducers) | ||
}) | ||
], | ||
declarations: [ | ||
ProviderWizardSummaryComponent, | ||
SummaryPropertyComponent, | ||
TestHostComponent | ||
], | ||
providers: [ | ||
{ provide: WidgetRegistry, useClass: DefaultWidgetRegistry } | ||
] | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
spyOn(store, 'dispatch'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should instantiate the component', async(() => { | ||
expect(app).toBeTruthy(); | ||
})); | ||
|
||
describe('ngOnChanges', () => { | ||
it('should set columns and sections if summary is provided', () => { | ||
instance.summary = { | ||
model: { | ||
name: 'foo', | ||
'@type': 'MetadataProvider' | ||
}, | ||
schema: SCHEMA, | ||
definition: MetadataProviderWizard | ||
}; | ||
fixture.detectChanges(); | ||
expect(app.sections).toBeDefined(); | ||
expect(app.columns).toBeDefined(); | ||
}); | ||
}); | ||
}); |
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
75 changes: 75 additions & 0 deletions
75
ui/src/app/metadata/provider/component/summary-property.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,75 @@ | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, Store, combineReducers } from '@ngrx/store'; | ||
|
||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { SummaryPropertyComponent } from './summary-property.component'; | ||
import * as fromRoot from '../reducer'; | ||
import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-schema-form'; | ||
import * as fromWizard from '../../../wizard/reducer'; | ||
import { Wizard } from '../../../wizard/model'; | ||
import { MetadataProvider } from '../../domain/model'; | ||
import { Property } from '../model/property'; | ||
|
||
@Component({ | ||
template: ` | ||
<summary-property [property]="property"></summary-property> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(SummaryPropertyComponent) | ||
public componentUnderTest: SummaryPropertyComponent; | ||
|
||
private _property; | ||
|
||
get property(): Property { | ||
return this._property; | ||
} | ||
|
||
set property(prop: Property) { | ||
this._property = prop; | ||
} | ||
} | ||
|
||
describe('Summary Property Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: SummaryPropertyComponent; | ||
let store: Store<fromRoot.State>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule.forRoot(), | ||
RouterTestingModule, | ||
SchemaFormModule.forRoot(), | ||
StoreModule.forRoot({ | ||
provider: combineReducers(fromRoot.reducers), | ||
wizard: combineReducers(fromWizard.reducers) | ||
}) | ||
], | ||
declarations: [ | ||
SummaryPropertyComponent, | ||
TestHostComponent | ||
], | ||
providers: [ | ||
{ provide: WidgetRegistry, useClass: DefaultWidgetRegistry } | ||
] | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
spyOn(store, 'dispatch'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should instantiate the component', async(() => { | ||
expect(app).toBeTruthy(); | ||
})); | ||
}); |
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,18 @@ | ||
import { reducer, initialState as snapshot } from './editor.reducer'; | ||
import { EditorActionTypes, ClearEditor } from '../action/editor.action'; | ||
|
||
describe('Provider Editor Reducer', () => { | ||
describe('undefined action', () => { | ||
it('should return the default state', () => { | ||
const result = reducer(snapshot, {} as any); | ||
|
||
expect(result).toEqual(snapshot); | ||
}); | ||
}); | ||
|
||
describe(`${EditorActionTypes.CLEAR}`, () => { | ||
it('should reset to initial state', () => { | ||
expect(reducer(snapshot, new ClearEditor())).toEqual(snapshot); | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
ui/src/app/metadata/provider/reducer/entity.reducer.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,18 @@ | ||
import { reducer, initialState as snapshot } from './entity.reducer'; | ||
import { EntityActionTypes, ClearProvider } from '../action/entity.action'; | ||
|
||
describe('Provider Editor Reducer', () => { | ||
describe('undefined action', () => { | ||
it('should return the default state', () => { | ||
const result = reducer(snapshot, {} as any); | ||
|
||
expect(result).toEqual(snapshot); | ||
}); | ||
}); | ||
|
||
describe(`${EntityActionTypes.CLEAR_PROVIDER}`, () => { | ||
it('should reset to initial state', () => { | ||
expect(reducer(snapshot, new ClearProvider())).toEqual(snapshot); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.