samedi 27 février 2016

expectGET not getting

I'm trying to write a test that verify's my routes exist & are working properly. One issue I'm having is that I can't figure out how to verify that a GET request has been made for my template URL. What am I doing wrong?

angular.module('businesses').config(['$stateProvider',
    function ($stateProvider) {
        // businesses state routing
        $stateProvider
                .state('businesses', {
                    abstract: true,
                    url: '/businesses',
                    template: '<ui-view/>',
                })

                .state('businesses.view', {
                    url: '/:businessId',
                    templateUrl: 'modules/businesses/client/views/admin/tabs/_tabs.html',
                })
                .state("businesses.view.settings", { url: "/settings", templateUrl: "modules/businesses/client/views/admin/tabs/settings.html" })
    }
]);



describe('Business Routes tests', function () {
    var $httpBackend, $state, $scope;

    beforeEach(module(ApplicationConfiguration.applicationModuleName))

    beforeEach(inject(function (_$rootScope_, _$state_, _$httpBackend_) {
        $scope = _$rootScope_.$new();
        $state = _$state_;
        $httpBackend = _$httpBackend_;
    }));

    describe("Route Tests", function () {
        afterEach(function(){
            //$httpBackend.flush();

            $httpBackend.verifyNoOutstandingExpectation();
            $httpBackend.verifyNoOutstandingRequest();

        })

        it("Should verify our route exists", function () {

            $state.go('businesses.view.settings', {businessId: 3333});

            $scope.$digest();
            $httpBackend.expectGET('/api/businesses').respond(200);
            $httpBackend.flush();
            expect($state.current.templateUrl).toEqual('modules/businesses/client/views/admin/tabs/settings.html');
            expect($state.current.url).toEqual('/settings');
            expect($state.current.name).toEqual('businesses.view.settings');


        });

    })


})

Aucun commentaire:

Enregistrer un commentaire