angular-nevera-generator
Version:
Yeoman AngularJS scaffold a webapp with Angular 1 written in ES6 (Babel), TypeScript through Webpack or SystemJS including tools Gulp 4, ESLint, Browsersync and Karma
45 lines (40 loc) • 1.44 kB
text/typescript
describe('TodoItem component', () => {
beforeEach(angular.mock.module('app', $provide => {
$provide.factory('todoItem', () => {
return {
templateUrl: 'app/components/TodoItem.html'
};
});
}));
beforeEach(angular.mock.module('app'));
it('should render correctly', angular.mock.inject(($rootScope: ng.IRootScopeService, $compile: ng.ICompileService) => {
const $scope = $rootScope.$new();
const element = $compile('<todo-item></todo-item>')($scope);
$scope.$digest();
const li = element.find('li');
expect(li).not.toBeNull();
}));
it('should call set editing to true', angular.mock.inject($componentController => {
const component = $componentController('todoItem', {}, {});
spyOn(component, 'handleDoubleClick').and.callThrough();
component.handleDoubleClick();
expect(component.handleDoubleClick).toHaveBeenCalled();
expect(component.editing).toEqual(true);
}));
it('should call onSave', angular.mock.inject($componentController => {
const bindings = {
todo: {
text: 'Use ngrx/store',
completed: false,
id: 0
},
onSave: () => {return; }
};
const component = $componentController('todoItem', {}, bindings);
spyOn(component, 'onSave').and.callThrough();
component.handleSave('Hello');
expect(component.onSave).toHaveBeenCalledWith({
todo: {text: 'Hello', id: 0}
});
}));
});