forked from tsai/budibase
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 { get } from 'svelte/store' |
||||
import { createDatasourcesStore } from "../datasources" |
import api from 'builderStore/api' |
||||
|
|
||||
const mockApi = { |
jest.mock('builderStore/api'); |
||||
post: () => ({}), |
|
||||
get: () => ({}), |
|
||||
patch: () => ({}), |
|
||||
delete: () => ({}), |
|
||||
put: () => ({}), |
|
||||
} |
|
||||
|
|
||||
|
import { createDatasourcesStore } from "../datasources" |
||||
|
|
||||
describe("Automation Data Object", () => { |
describe("Automation Data Object", () => { |
||||
let store |
let store = createDatasourcesStore() |
||||
|
|
||||
beforeEach(() => { |
beforeEach(() => { |
||||
store = createDatasourcesStore(mockApi) |
store.init() |
||||
}) |
}) |
||||
|
|
||||
it("Inits properly", () => { |
it("Inits properly", () => { |
||||
|
|
||||
const value = get(store) |
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