mirror of https://github.com/Budibase/budibase.git
4 changed files with 30 additions and 15 deletions
@ -0,0 +1,26 @@ |
|||
import api from 'builderStore/api' |
|||
|
|||
jest.mock('builderStore/api'); |
|||
|
|||
const PERMISSIONS_FOR_RESOURCE = { |
|||
"write": "BASIC", |
|||
"read": "BASIC" |
|||
} |
|||
|
|||
import { createPermissionStore } from "../permissions" |
|||
|
|||
describe("Permissions Store", () => { |
|||
const store = createPermissionStore() |
|||
|
|||
it("fetches permissions for specific resource", async () => { |
|||
api.get.mockReturnValueOnce({ json: () => PERMISSIONS_FOR_RESOURCE}) |
|||
|
|||
const resourceId = "ta_013657543b4043b89dbb17e9d3a4723a" |
|||
|
|||
const permissions = await store.forResource(resourceId) |
|||
|
|||
expect(api.get).toBeCalledWith(`/api/permission/${resourceId}`) |
|||
expect(permissions).toEqual(PERMISSIONS_FOR_RESOURCE) |
|||
|
|||
}) |
|||
}) |
|||
Loading…
Reference in new issue