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-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('order', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2018-10-10 10:55:04 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
2018-10-10 10:55:04 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2018-10-10 12:03:56 +00:00
|
|
|
controller = $componentController('vnOrderSummary');
|
|
|
|
controller.order = {id: 1};
|
2018-10-10 10:55:04 +00:00
|
|
|
}));
|
|
|
|
|
2018-10-10 12:03:56 +00:00
|
|
|
describe('getSummary()', () => {
|
2018-10-10 10:55:04 +00:00
|
|
|
it('should perform a GET query and define summary property', () => {
|
|
|
|
let res = {id: 1, nickname: 'Batman'};
|
2018-10-10 12:03:56 +00:00
|
|
|
$httpBackend.when('GET', `/order/api/Orders/1/summary`).respond(200, res);
|
|
|
|
$httpBackend.expect('GET', `/order/api/Orders/1/summary`);
|
|
|
|
controller.setSummary();
|
2018-10-10 10:55:04 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.summary).toBeDefined();
|
|
|
|
expect(controller.summary.nickname).toEqual('Batman');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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)');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|