mirror of https://github.com/Budibase/budibase.git
11 changed files with 30 additions and 47 deletions
@ -1,26 +0,0 @@ |
|||
import { database } from "../" |
|||
|
|||
describe("Backend DataSources Store", () => { |
|||
|
|||
let state; |
|||
let unsub; |
|||
|
|||
beforeEach(() => { |
|||
unsub = database.subscribe(s => state = s); |
|||
}) |
|||
afterEach(() => { |
|||
unsub() |
|||
}) |
|||
|
|||
it("initialises correctly", () => { |
|||
expect(state.list, []) |
|||
}) |
|||
}) |
|||
|
|||
const api = { |
|||
post: () => ({}), |
|||
get: () => ({}), |
|||
patch: () => ({}), |
|||
delete: () => ({}), |
|||
put: () => ({}), |
|||
} |
|||
@ -1,24 +1,33 @@ |
|||
import { get } from 'svelte/store' |
|||
import { createDatasourcesStore } from "../datasources" |
|||
import api from 'builderStore/api' |
|||
|
|||
const mockApi = { |
|||
post: () => ({}), |
|||
get: () => ({}), |
|||
patch: () => ({}), |
|||
delete: () => ({}), |
|||
put: () => ({}), |
|||
} |
|||
jest.mock('builderStore/api'); |
|||
|
|||
import { createDatasourcesStore } from "../datasources" |
|||
|
|||
describe("Automation Data Object", () => { |
|||
let store |
|||
let store = createDatasourcesStore() |
|||
|
|||
beforeEach(() => { |
|||
store = createDatasourcesStore(mockApi) |
|||
store.init() |
|||
}) |
|||
|
|||
it("Inits properly", () => { |
|||
|
|||
const value = get(store) |
|||
expect(value).toBe(true) |
|||
expect(value).toEqual({ list: [], selected: null}) |
|||
}) |
|||
|
|||
it("Fetch returns and updates store", async () => { |
|||
api.get.mockReturnValueOnce({ json: () => 'some-cool-value'}) |
|||
|
|||
store.fetch() |
|||
|
|||
|
|||
|
|||
expect(api.get).toBeCalledWith(`/api/datasources`) |
|||
|
|||
|
|||
// expect(get(store)).toEqual({ list: [], selected: null})
|
|||
}) |
|||
}) |
|||
|
|||
Loading…
Reference in new issue