Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis
Last active September 2, 2017 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdyrrahitis/536a9e9d56a506491a90c0c260de92e5 to your computer and use it in GitHub Desktop.
Save gdyrrahitis/536a9e9d56a506491a90c0c260de92e5 to your computer and use it in GitHub Desktop.
declare type Locals = { $scope?: ng.IScope, [key: string]: any };
let createComponent: (name: string, locals: Locals, bindings: any) => any;
let $state: ng.ui.IStateService;
let scope: ng.IScope;
beforeEach(inject((_$componentController_: ng.IComponentControllerService, _$state_, _$rootScope_) => {
createComponent = (name, locals: Locals, bindings) => _$componentController_(name, locals, bindings);
$state = _$state_;
scope = _$rootScope_.$new();
}));
it("should navigate to /todo/:id when method is called", () => {
// arrange
let component = createComponent("todoHome", { $scope: scope }, {});
// act
component.showTodo("1");
scope.$digest();
// assert
expect($state.current.name).toBe("todo");
expect($state.href($state.current.name)).toBe("/todo/1");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment