2018-11-26 10:41:11 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Ticket', () => {
|
|
|
|
describe('Component vnTicketLog', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
2018-11-26 10:41:11 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
controller = $componentController('vnTicketLog', {$scope: $scope});
|
|
|
|
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('logs setter', () => {
|
|
|
|
it('should call the function getInstance() twice', () => {
|
|
|
|
spyOn(controller, 'getInstance');
|
|
|
|
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
|
|
|
|
|
|
|
expect(controller.getInstance.calls.count()).toBe(2);
|
|
|
|
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
|
|
|
|
expect(controller.getInstance).toHaveBeenCalledWith({id: 2});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getInstance(instance)', () => {
|
|
|
|
it('should transform the object given in to an array', () => {
|
|
|
|
const newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance);
|
|
|
|
|
|
|
|
expect(newInstance).toEqual([{key: 'id', value: 1}]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|