-
-
Save gdyrrahitis/50f966f11bb8cfbcc8eeacb5d23a81ad to your computer and use it in GitHub Desktop.
Help Spec
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
import * as angular from "angular"; | |
import { HelpModule, HelpComponent } from "./index"; | |
declare type Locals = { $scope?: ng.IScope, [key: string]: any }; | |
declare type ComponentControllerArgs = <T, TBinding>(componentName: string, | |
locals: { $scope?: ng.IScope, [key: string]: any }, | |
bindings?: TBinding, ident?: string) => T; | |
describe("Help", () => { | |
let createComponent: ComponentControllerArgs; | |
let $state: ng.ui.IStateService; | |
let $rootScope: ng.IRootScopeService; | |
let state: string = "help"; | |
beforeEach(angular.mock.module(HelpModule)); | |
beforeEach(angular.mock.module(HelpModule, ($stateProvider: ng.ui.IStateProvider, $locationProvider: ng.ILocationProvider) => { | |
$locationProvider.html5Mode({ | |
enabled: true, | |
requireBase: false | |
}).hashPrefix("!"); | |
$stateProvider.state("home", { url: "/home" }); | |
})); | |
beforeEach(inject((_$componentController_: ng.IComponentControllerService, _$state_: ng.ui.IStateService, | |
_$rootScope_: ng.IRootScopeService) => { | |
$state = _$state_; | |
$rootScope = _$rootScope_; | |
createComponent = (name: string, locals: Locals, bindings: {}) => _$componentController_(name, locals, bindings); | |
})); | |
describe("Component", () => { | |
it("should be routed component", () => { | |
// act | |
$state.go(state); | |
$rootScope.$digest(); | |
// assert | |
expect($state.current.component).toBe("pcardHelp", "Component is not set"); | |
expect($state.current.name).toBe(state, "State is not set"); | |
expect($state.href($state.current.name)).toBe("/help"); | |
}); | |
it("should redirect to home if route is wrong", () => { | |
// act | |
$state.go("non-existent"); | |
$rootScope.$digest(); | |
// assert | |
expect($state.href($state.current.name)).toBe("/home"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment