-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(uiSrefStatus): emit state/params in events
- Loading branch information
gcca
committed
Sep 11, 2017
1 parent
2b7985b
commit d393607
Showing
2 changed files
with
62 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Component, DebugElement } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { SrefStatus, UISrefStatus } from '../../src/directives/uiSrefStatus'; | ||
import { UIRouterModule } from '../../src/uiRouterNgModule'; | ||
|
||
describe('uiSrefStatus', () => { | ||
@Component({ | ||
template: '<a uiSref="foo" (uiSrefStatus)="updated($event)"></a>', | ||
}) | ||
class TestComponent { | ||
updated(event: SrefStatus) { | ||
throw new Error('updated() method must be spied'); | ||
} | ||
} | ||
|
||
let component: TestComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<TestComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TestComponent], | ||
imports: [UIRouterModule.forRoot({ | ||
states: [{ name: 'foo' }], | ||
useHash: true, | ||
})] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TestComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
de = fixture.debugElement.query(By.directive(UISrefStatus)); | ||
}); | ||
|
||
describe('when click on `foo` uiSref', () => { | ||
beforeEach(async(() => { | ||
spyOn(component, 'updated'); | ||
de.triggerEventHandler('click', {}); | ||
})); | ||
|
||
it('should emit a event with identifier equals to `foo`', () => { | ||
expect(component.updated).toHaveBeenCalledWith(jasmine.objectContaining({ | ||
identifier: 'foo', | ||
})); | ||
}); | ||
}); | ||
}); |