By Andi Marek / @andimarek
errare humanum est
Based on Return on investment (ROI)
From Top to Bottom: Less integrated
describe('Testing myService', function () {
var myService;
var aDependencyMock;
beforeEach(function () {
aDependencyMock = {
someFunction: function () {
}
};
module('myModule.myService');
module(function ($provide) {
$provide.value('aDependency', aDependencyMock);
});
inject(function (_myService_) {
myService = _myService_;
});
});
it('service should be defined', function () {
expect(myService).toBeDefined();
});
});
describe('Testing myDirective', function () {
var element;
var $scope;
beforeEach(function () {
module('myModule.myDirectice');
inject(function ($compile, $rootScope) {
$scope = $rootScope.$new();
element = angular.element('<myDirective/>');
$compile(element)($scope);
$scope.$digest();
});
});
it('now test element', function () {
});
});
it('should call methodX on click', function () {
spyOn($scope, 'methodX');
element.find('.button').click();
expect($scope.methodX).toHaveBeenCalled();
});
describe('E2E Test', function () {
beforeEach(function () {
browser().navigateTo('http://localhost/url/to/test/index.html');
});
it("should show a dialog", function () {
element('.show-dialog').click();
expect(element(".dialog").count()).toBe(1);
});
});