44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
import './index.js';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('InvoiceOut', () => {
|
|
describe('Component summary', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
let $scope;
|
|
|
|
beforeEach(ngModule('invoiceOut'));
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
|
$httpBackend = _$httpBackend_;
|
|
$scope = $rootScope.$new();
|
|
const $element = angular.element('<vn-invoice-out-summary></vn-invoice-out-summary>');
|
|
controller = $componentController('vnInvoiceOutSummary', {$element, $scope});
|
|
controller._invoiceOut = {id: 1};
|
|
controller.$.ticketsModel = crudModel;
|
|
}));
|
|
|
|
describe('getSummary()', () => {
|
|
it('should perform a query to set summary', () => {
|
|
$httpBackend.expect('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for');
|
|
controller.getSummary();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.summary).toEqual('the data you are looking for');
|
|
});
|
|
});
|
|
|
|
describe('getTickets()', () => {
|
|
it('should perform a and then call to the ticketModel refresh() method', () => {
|
|
jest.spyOn(controller.$.ticketsModel, 'refresh');
|
|
|
|
controller.getTickets();
|
|
$scope.$apply();
|
|
|
|
expect(controller.$.ticketsModel.url).toEqual('InvoiceOuts/1/getTickets');
|
|
expect(controller.$.ticketsModel.refresh).toHaveBeenCalledWith();
|
|
});
|
|
});
|
|
});
|
|
});
|