NoctisHsu
11/23/2016 - 10:09 AM

LocationService.spec.js

it('取得縣市資料Promise.ver', function () {
        const deferred = $q.defer();
        deferred.resolve(fakeCitys);

        var apiPath = '/webapi/GetLocations';
        $httpBackend.when('GET',apiPath).respond(function(){
            return [200, JSON.stringify(fakeCitys)];
        });
        var callback = sinon.spy($http, "get").withArgs(apiPath);

        var res = LocationService.GetLocationsPromise();
        $httpBackend.flush();
        res.should.deep.equal(deferred.promise);
        callback.calledOnce.should.is.true;

    });