47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import './index';
|
|
|
|
describe('Order', () => {
|
|
describe('Component vnOrderSummary', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('order'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
const $element = angular.element('<vn-order-summary></vn-order-summary>');
|
|
controller = $componentController('vnOrderSummary', {$element});
|
|
controller.order = {id: 1};
|
|
}));
|
|
|
|
describe('getSummary()', () => {
|
|
it('should now perform a GET query and define the summary property', () => {
|
|
let res = {id: 1, nickname: 'Batman'};
|
|
$httpBackend.when('GET', `Orders/1/summary`).respond(200, res);
|
|
$httpBackend.expect('GET', `Orders/1/summary`);
|
|
controller.setSummary();
|
|
$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)');
|
|
});
|
|
});
|
|
});
|
|
});
|