-
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
10 changed files
with
522 additions
and
26 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
107 changes: 107 additions & 0 deletions
107
ui/src/app/metadata/configuration/container/restore-edit-step.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,107 @@ | ||
import { Component, ViewChild, NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, combineReducers, Store } from '@ngrx/store'; | ||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { RestoreEditStepComponent } from './restore-edit-step.component'; | ||
import * as fromConfiguration from '../reducer'; | ||
import * as fromProviders from '../../provider/reducer'; | ||
import * as fromResolvers from '../../resolver/reducer'; | ||
import * as fromWizard from '../../../wizard/reducer'; | ||
import { MockI18nModule } from '../../../../testing/i18n.stub'; | ||
|
||
import { | ||
RestoreActionTypes | ||
} from '../action/restore.action'; | ||
import { WizardActionTypes } from '../../../wizard/action/wizard.action'; | ||
|
||
@Component({ | ||
template: ` | ||
<restore-edit-step></restore-edit-step> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(RestoreEditStepComponent) | ||
public componentUnderTest: RestoreEditStepComponent; | ||
} | ||
|
||
describe('Restore Version Edit Step Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: RestoreEditStepComponent; | ||
let store: Store<fromConfiguration.State>; | ||
let dispatchSpy; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule, | ||
StoreModule.forRoot({ | ||
'metadata-configuration': combineReducers(fromConfiguration.reducers), | ||
'provider': combineReducers(fromProviders.reducers), | ||
'resolver': combineReducers(fromResolvers.reducers), | ||
'wizard': combineReducers(fromWizard.reducers) | ||
}), | ||
MockI18nModule, | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
RestoreEditStepComponent, | ||
TestHostComponent | ||
], | ||
schemas: [ | ||
NO_ERRORS_SCHEMA | ||
] | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
dispatchSpy = spyOn(store, 'dispatch'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should compile', () => { | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
describe('onChange', () => { | ||
it('should dispatch an update changes event', () => { | ||
app.onChange({ name: 'test' }); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(RestoreActionTypes.UPDATE_RESTORATION_REQUEST); | ||
}); | ||
}); | ||
|
||
describe('updateStatus', () => { | ||
it('should dispatch an update form status event', () => { | ||
app.updateStatus([{ value: 'foo' }, 'common']); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(RestoreActionTypes.UPDATE_STATUS); | ||
}); | ||
|
||
it('should dispatch an update form status event', () => { | ||
app.updateStatus([{}, 'common']); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(RestoreActionTypes.UPDATE_STATUS); | ||
}); | ||
}); | ||
|
||
describe('updateLock', () => { | ||
it('should dispatch a LockEditor event when passed a locked status', () => { | ||
app.updateLock(true); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(WizardActionTypes.LOCK); | ||
}); | ||
|
||
it('should dispatch a UnlockEditor event when passed a locked status', () => { | ||
app.updateLock(false); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(WizardActionTypes.UNLOCK); | ||
}); | ||
}); | ||
}); |
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
79 changes: 79 additions & 0 deletions
79
ui/src/app/metadata/configuration/container/restore-edit.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,79 @@ | ||
import { Component, ViewChild, NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, combineReducers, Store } from '@ngrx/store'; | ||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { RestoreEditComponent } from './restore-edit.component'; | ||
import * as fromConfiguration from '../reducer'; | ||
import * as fromProviders from '../../provider/reducer'; | ||
import * as fromResolvers from '../../resolver/reducer'; | ||
import { MockI18nModule } from '../../../../testing/i18n.stub'; | ||
import { RestoreActionTypes } from '../action/restore.action'; | ||
|
||
@Component({ | ||
template: ` | ||
<restore-edit></restore-edit> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(RestoreEditComponent) | ||
public componentUnderTest: RestoreEditComponent; | ||
} | ||
|
||
describe('Restore Version Edit Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: RestoreEditComponent; | ||
let store: Store<fromConfiguration.State>; | ||
let dispatchSpy; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule, | ||
StoreModule.forRoot({ | ||
'metadata-configuration': combineReducers(fromConfiguration.reducers), | ||
'provider': combineReducers(fromProviders.reducers), | ||
'resolver': combineReducers(fromResolvers.reducers) | ||
}), | ||
MockI18nModule, | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
RestoreEditComponent, | ||
TestHostComponent | ||
], | ||
schemas: [ NO_ERRORS_SCHEMA ] | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
dispatchSpy = spyOn(store, 'dispatch'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should compile', () => { | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
describe('save', () => { | ||
it('should dispatch a save request event', () => { | ||
app.save(); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(RestoreActionTypes.RESTORE_VERSION_REQUEST); | ||
}); | ||
}); | ||
|
||
describe('cancel', () => { | ||
it('should dispatch a cancel request event', () => { | ||
app.cancel(); | ||
expect(store.dispatch).toHaveBeenCalled(); | ||
expect(dispatchSpy.calls.mostRecent().args[0].type).toBe(RestoreActionTypes.CANCEL_RESTORE); | ||
}); | ||
}); | ||
}); |
82 changes: 82 additions & 0 deletions
82
ui/src/app/metadata/configuration/container/version-options.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,82 @@ | ||
import { Component, ViewChild, NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, combineReducers } from '@ngrx/store'; | ||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { VersionOptionsComponent } from './version-options.component'; | ||
import * as fromConfiguration from '../reducer'; | ||
import * as fromProviders from '../../provider/reducer'; | ||
import * as fromResolvers from '../../resolver/reducer'; | ||
import { MockI18nModule } from '../../../../testing/i18n.stub'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
import { ViewportScroller } from '@angular/common'; | ||
|
||
@Component({ | ||
template: ` | ||
<version-options-page></version-options-page> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(VersionOptionsComponent) | ||
public componentUnderTest: VersionOptionsComponent; | ||
} | ||
|
||
describe('Metadata Version Options Page Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: VersionOptionsComponent; | ||
let scroller: ViewportScroller; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule, | ||
StoreModule.forRoot({ | ||
'metadata-configuration': combineReducers(fromConfiguration.reducers), | ||
'provider': combineReducers(fromProviders.reducers), | ||
'resolver': combineReducers(fromResolvers.reducers) | ||
}), | ||
MockI18nModule, | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
VersionOptionsComponent, | ||
TestHostComponent | ||
], | ||
schemas: [ NO_ERRORS_SCHEMA ] | ||
}).compileComponents(); | ||
|
||
scroller = TestBed.get(ViewportScroller); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should compile', () => { | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
describe('setModel method', () => { | ||
it('should set attributes based on the passed data', () => { | ||
app.setModel({ id: 'foo', '@type': 'bar' } as Metadata); | ||
expect(app.id).toBe('foo'); | ||
expect(app.kind).toBe('provider'); | ||
|
||
app.setModel({ resourceId: 'baz' } as Metadata); | ||
expect(app.id).toBe('baz'); | ||
expect(app.kind).toBe('resolver'); | ||
}); | ||
}); | ||
|
||
describe('onScrollTo method', () => { | ||
it('should set attributes based on the passed data', () => { | ||
spyOn(scroller, 'scrollToAnchor'); | ||
app.onScrollTo('foo'); | ||
expect(scroller.scrollToAnchor).toHaveBeenCalledWith('foo'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.