* Add vue-rx, rxjs and lodash as dependencies * Added vue-rx plugin integration to nuxt config * Initial settings store implementation * Add babel plugin for private class properties to for Jest * Add DispatchingStore test spec * Initial settings code * Reactive Streams for fb current user and id token * Fix typo * Migrate index and graphql pages to the new store * Migrate network strategy to the new store * Fixed Section.vue errors * Fix getSettingSubject issue * Migrate fb settings reference in components to the new state system * Add typings for lodash as dev dependency * Load setting * Load initial sync setting values * Update proxy url * Add typescript support * Rewrite Settings store to TypeScript * Port Settings page to TypeScript as reference * Move all store migrations to a separate file * Delete test file for fb.js * Add ts-jest as dev dependency * Remove firebase-mock as dependency * Remove FRAME_COLORS_ENABLED settings value
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
import { cancelRunningRequest, sendNetworkRequest } from "../network"
|
|
|
|
import AxiosStrategy, { cancelRunningAxiosRequest } from "../strategies/AxiosStrategy"
|
|
import ExtensionStrategy, {
|
|
cancelRunningExtensionRequest,
|
|
hasExtensionInstalled,
|
|
} from "../strategies/ExtensionStrategy"
|
|
|
|
jest.mock("../strategies/AxiosStrategy", () => ({
|
|
__esModule: true,
|
|
default: jest.fn(() => Promise.resolve()),
|
|
cancelRunningAxiosRequest: jest.fn(() => Promise.resolve()),
|
|
}))
|
|
|
|
jest.mock("../strategies/ExtensionStrategy", () => ({
|
|
__esModule: true,
|
|
default: jest.fn(() => Promise.resolve()),
|
|
cancelRunningExtensionRequest: jest.fn(() => Promise.resolve()),
|
|
hasExtensionInstalled: jest.fn(),
|
|
}))
|
|
|
|
jest.mock("~/newstore/settings", () => {
|
|
return {
|
|
settingsStore: {
|
|
value: {
|
|
EXTENSIONS_ENABLED: false
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
global.$nuxt = {
|
|
$loading: {
|
|
finish: jest.fn(() => Promise.resolve()),
|
|
},
|
|
}
|
|
|
|
beforeEach(() => {
|
|
jest.clearAllMocks() // Reset the call count for the mock functions
|
|
})
|
|
|
|
describe("cancelRunningRequest", () => {
|
|
test("cancels only axios request if extension not allowed in settings and extension is installed", () => {
|
|
hasExtensionInstalled.mockReturnValue(true)
|
|
|
|
cancelRunningRequest()
|
|
|
|
expect(cancelRunningExtensionRequest).not.toHaveBeenCalled()
|
|
expect(cancelRunningAxiosRequest).toHaveBeenCalled()
|
|
})
|
|
|
|
test("cancels only axios request if extension is not allowed and not installed", () => {
|
|
hasExtensionInstalled.mockReturnValue(false)
|
|
|
|
cancelRunningRequest()
|
|
|
|
expect(cancelRunningExtensionRequest).not.toHaveBeenCalled()
|
|
expect(cancelRunningAxiosRequest).toHaveBeenCalled()
|
|
})
|
|
})
|
|
|
|
describe("sendNetworkRequest", () => {
|
|
|
|
test("runs only axios request if extension not allowed in settings and extension is installed and clears the progress bar", async () => {
|
|
hasExtensionInstalled.mockReturnValue(true)
|
|
|
|
await sendNetworkRequest({})
|
|
|
|
expect(ExtensionStrategy).not.toHaveBeenCalled()
|
|
expect(AxiosStrategy).toHaveBeenCalled()
|
|
expect(global.$nuxt.$loading.finish).toHaveBeenCalled()
|
|
})
|
|
|
|
test("runs only axios request if extension is not allowed and not installed and clears the progress bar", async () => {
|
|
hasExtensionInstalled.mockReturnValue(false)
|
|
|
|
await sendNetworkRequest({})
|
|
|
|
expect(ExtensionStrategy).not.toHaveBeenCalled()
|
|
expect(AxiosStrategy).toHaveBeenCalled()
|
|
expect(global.$nuxt.$loading.finish).toHaveBeenCalled()
|
|
})
|
|
})
|