Created
February 28, 2017 14:54
-
-
Save washingtonsoares/ae2348ad69dde0f3c73328238f50ed94 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 HomeModule from './home' | |
describe('Home', () => { | |
let $rootScope, $state, $location, $componentController, $compile; | |
beforeEach(window.module(HomeModule)); | |
beforeEach(inject(($injector) => { | |
$rootScope = $injector.get('$rootScope'); | |
$componentController = $injector.get('$componentController'); | |
$state = $injector.get('$state'); | |
$location = $injector.get('$location'); | |
$compile = $injector.get('$compile'); | |
})); | |
describe('Module', () => { | |
// top-level specs: i.e., routes, injection, naming | |
it('default component should be home', () => { | |
$location.url('/'); | |
$rootScope.$digest(); | |
expect($state.current.component).to.eq('home'); | |
}); | |
}); | |
describe('Controller', () => { | |
// controller specs | |
let controller; | |
beforeEach(() => { | |
controller = $componentController('home', { | |
$scope: $rootScope.$new() | |
}); | |
}); | |
it('has a name property', () => { // erase if removing this.name from the controller | |
expect(controller).to.have.property('name'); | |
}); | |
}); | |
describe('View', () => { | |
// view layer specs. | |
let scope, template; | |
beforeEach(() => { | |
scope = $rootScope.$new(); | |
template = $compile('<home></home>')(scope); | |
scope.$apply(); | |
}); | |
it('has name in template', () => { | |
expect(template.find('h1').html()).to.eq('Found in home.html'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment