UNPKG

@nuskin/ns-checkout

Version:

Ecomm3 Checkout module

140 lines (123 loc) 4.61 kB
describe("OrderSummaryCtrl", function() { let controller; let $scope; let $httpBackend; let timeout; afterEach(function() { if (!$scope.$$phase) { $httpBackend.verifyNoOutstandingExpectation(); $httpBackend.verifyNoOutstandingRequest(); } }); beforeEach(function() { angular.mock.module('checkout'); // The init is required before any injects for each spec file: nuskin.init({country:'US', language: 'en', env: 'test', baseUrl: 'https://test.nuskin.com'}); }); beforeEach(inject(function ( _$httpBackend_, $rootScope, $controller, $filter, $q, $http, $location, $timeout, _nsAdrOptions_, _nsShipping_, _nsTimeDelivery_, _nsPayment_, _nsProduct_, _nsOrder_, _nsUtil_, _nsSection_, _nsExternalPayment_, _nsSections_, _nsDowntime_, _tdcService_, _nsADRType_, _nsAdrUtil_, _nsGuestSignup_, _googleMapsApi_, _NgMap_) { try { nuskin.newAccount.UserService.setUser({ id: 123, availablePoints: 300, sponsorId: 'US123456', countryCd: 'US', loginTime: new Date().getTime() }); nuskin.newAccount.UserService.setLoggedIn(true); timeout = $timeout; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); controller = $controller('OrderSummaryCtrl', { '$scope': $scope, '$filter': $filter, '$q': $q, '$http': $http, '$location': $location, '$timeout': $timeout, 'nsAdrOptions': _nsAdrOptions_, 'nsShipping': _nsShipping_, 'nsTimeDelivery': _nsTimeDelivery_, 'nsPayment': _nsPayment_, 'nsProduct': _nsProduct_, 'nsOrder': _nsOrder_, 'nsUtil': _nsUtil_, 'nsSection': _nsSection_, // not to be confused with sections 'nsExternalPayment': _nsExternalPayment_, 'nsSections': _nsSections_, // not to be confused with section 'nsDowntime': _nsDowntime_, 'tdcService': _tdcService_, 'nsADRType': _nsADRType_, 'nsAdrUtil': _nsAdrUtil_, 'nsGuestSignup': _nsGuestSignup_, 'googleMapsApi': _googleMapsApi_, 'NgMap': _NgMap_ }); } catch(e) { console.warn('Caught exception: ' + e.message); } })); describe('init', () => { it('$httpBackend', () => { expect($httpBackend).toBeDefined(); }); it('$scope', () => { expect($scope).toBeDefined(); }); it('$scope.gmap', () => { expect(typeof $scope.gmap).toEqual('object'); expect($scope.gmap.googleMapsApiUrl).toMatch(/^https:\/\/maps.google.com\/maps\/api/); expect($scope.gmap.markers).toBe(null); expect($scope.gmap.selectedMarker).toBe(null); expect($scope.gmap.instance).toBe(null); }); it('$scope.pickupMapSelected', () => { expect($scope.pickupMapSelected).toBeUndefined(); }); it('$scope.showCheckout', () => { expect($scope.showCheckout).toEqual(true); }); it('$scope.runConfig', () => { expect($scope.runConfig).toBeDefined(); expect(typeof $scope.runConfig).toEqual('object'); }); it('$scope.buyer', () => { expect($scope.buyer).toBeDefined(); expect(typeof $scope.buyer).toEqual('object'); }); // Not a big deal to not test the checkoutSetup as that should all be undefined here // Since the checkoutSetup is loaded from an index.html and that's not setup in this spec. it('$scope.isSummerPromo', () => { expect($scope.isSummerPromo).toEqual(false); }); }); describe('getCartUrl', () => { it('should return default url', () => { expect($scope.getCartUrl()).toEqual('cart.html#/cart'); }); }); });