"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
var __webpack_exports__ = {};
const external_axios_namespaceObject = require("axios");
var external_axios_default = /*#__PURE__*/ __webpack_require__.n(external_axios_namespaceObject);
const external_APIClient_js_namespaceObject = require("../APIClient.js");
describe('APIClient', ()=>{
    describe('axios', ()=>{
        it('case 1', ()=>{
            const apiClient = new external_APIClient_js_namespaceObject.APIClient();
            expect(apiClient.axios).toBeDefined();
            expect(typeof apiClient.axios).toBe('function');
            expect(typeof apiClient.axios.request).toBe('function');
        });
        it('case 2', ()=>{
            const apiClient = new external_APIClient_js_namespaceObject.APIClient({
                baseURL: 'http://localhost/api/'
            });
            expect(apiClient.axios.defaults.baseURL).toBe('http://localhost/api/');
        });
        it('case 3', ()=>{
            const instance = external_axios_default().create();
            const apiClient = new external_APIClient_js_namespaceObject.APIClient(instance);
            expect(apiClient.axios).toBe(instance);
        });
    });
    test('should reset role when role is not found', async ()=>{
        const instance = external_axios_default().create();
        instance.interceptors.response.use((response)=>response, (error)=>{
            error = {
                response: {
                    data: {
                        errors: [
                            {
                                code: 'ROLE_NOT_FOUND_ERR'
                            }
                        ]
                    }
                }
            };
            throw error;
        });
        const apiClient = new external_APIClient_js_namespaceObject.APIClient(instance);
        apiClient.app = {};
        apiClient.auth.setRole('not-found');
        expect(apiClient.auth.role).toBe('not-found');
        try {
            await apiClient.request({
                method: 'GET',
                url: '/api/test'
            });
        } catch (err) {
            console.log(err);
            expect(err).toBeDefined();
            expect(err.response.data.errors[0].code).toBe('ROLE_NOT_FOUND_ERR');
        }
        expect(apiClient.auth.role).toBeFalsy();
    });
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
