2018-10-10 10:55:04 +00:00
|
|
|
import './index';
|
|
|
|
|
2018-10-10 12:03:56 +00:00
|
|
|
describe('Order', () => {
|
|
|
|
describe('Component vnOrderSummary', () => {
|
2018-10-10 10:55:04 +00:00
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('order'));
|
2018-10-10 10:55:04 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2018-10-10 10:55:04 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-03-17 14:18:02 +00:00
|
|
|
const $element = angular.element('<vn-order-summary></vn-order-summary>');
|
|
|
|
controller = $componentController('vnOrderSummary', {$element});
|
2018-10-10 12:03:56 +00:00
|
|
|
controller.order = {id: 1};
|
2018-10-10 10:55:04 +00:00
|
|
|
}));
|
|
|
|
|
2018-10-10 12:03:56 +00:00
|
|
|
describe('getSummary()', () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
it('should now perform a GET query and define the summary property', () => {
|
2020-04-28 12:26:02 +00:00
|
|
|
let res = {
|
|
|
|
id: 1,
|
|
|
|
nickname: 'Batman'
|
|
|
|
};
|
|
|
|
$httpBackend.expectGET(`Orders/1/summary`).respond(res);
|
2018-10-10 12:03:56 +00:00
|
|
|
controller.setSummary();
|
2018-10-10 10:55:04 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
expect(controller.summary).toEqual(res);
|
2018-10-10 10:55:04 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('formattedAddress()', () => {
|
|
|
|
it('should return a full fromatted address with city and province', () => {
|
|
|
|
controller.summary = {
|
|
|
|
address: {
|
|
|
|
province: {
|
|
|
|
name: 'Gotham'
|
|
|
|
},
|
|
|
|
street: '1007 Mountain Drive',
|
|
|
|
city: 'Gotham'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(controller.formattedAddress).toEqual('1007 Mountain Drive - Gotham (Gotham)');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|