Skip to content

Commit

Permalink
Fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed Mar 9, 2023
1 parent 3f6e10f commit 0863d20
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/web-app-files/tests/unit/helpers/share/link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ const mockResource = {

const getAbilityMock = (hasPermission) => mock<Ability>({ can: () => hasPermission })

let returnBitmask = 1
jest.mock('web-client/src/helpers/share', () => ({
LinkShareRoles: {
getByName: jest.fn().mockReturnValue({ bitmask: jest.fn(() => returnBitmask) })
}
}))

describe('createQuicklink', () => {
it('should create a quicklink with the correct parameters', async () => {
const args: CreateQuicklink = {
Expand Down Expand Up @@ -77,6 +84,7 @@ describe('createQuicklink', () => {
it.each(['viewer', 'internal'])(
'should create a quicklink without a password if no password is provided and capabilities set to default %s',
async (role) => {
returnBitmask = role === 'viewer' ? 1 : 0
mockStore.state.user.capabilities.files_sharing.quickLink.default_role = role

const args: CreateQuicklink = {
Expand Down

0 comments on commit 0863d20

Please sign in to comment.