salix/modules/ticket/front/log/index.spec.js

38 lines
1.4 KiB
JavaScript

import './index';
describe('Ticket', () => {
describe('Component vnTicketLog', () => {
let $componentController;
let $scope;
let controller;
beforeEach(ngModule('ticket'));
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}]);
});
});
});
});