-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: show quota when used quota is 0
Refs: SHELL-184 (#381)
- Loading branch information
1 parent
a23ea94
commit 06617d8
Showing
2 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/settings/components/general-settings/user-quota.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { produce } from 'immer'; | ||
|
||
import UserQuota from './user-quota'; | ||
import { useAccountStore } from '../../../store/account'; | ||
import { screen, setup } from '../../../test/utils'; | ||
|
||
const quotaMax = 100; | ||
function setupAccountStore(usedQuota = 0): void { | ||
useAccountStore.setState( | ||
produce((state) => { | ||
state.usedQuota = usedQuota; | ||
state.settings.attrs.zimbraMailQuota = quotaMax; | ||
}) | ||
); | ||
} | ||
describe('User Quota', () => { | ||
describe('Quota description', () => { | ||
it.each([ | ||
['even if it is 0', 0], | ||
['if it is less than zimbraMailQuota', quotaMax - 1], | ||
['if it is higher than zimbraMailQuota', quotaMax + 1] | ||
])('should render the % of quota used message %s', (description, quotaUsed) => { | ||
setupAccountStore(quotaUsed); | ||
setup(<UserQuota mobileView={false} />); | ||
expect(screen.getByText(/user's quota/i)).toBeVisible(); | ||
expect( | ||
screen.getByText(`You have filled ${quotaUsed}% of the available space`) | ||
).toBeVisible(); | ||
}); | ||
|
||
it.each([0, -1])( | ||
'should render "You have unlimited space available" message when zimbraMailQuota is %s', | ||
(quota) => { | ||
useAccountStore.setState( | ||
produce((state) => { | ||
state.settings.attrs.zimbraMailQuota = quota; | ||
}) | ||
); | ||
setup(<UserQuota mobileView={false} />); | ||
expect(screen.getByText(`You have unlimited space available`)).toBeVisible(); | ||
} | ||
); | ||
|
||
it('should render "It seems that all available space is full" message when the quota used is equal to zimbraMailQuota', () => { | ||
setupAccountStore(quotaMax); | ||
setup(<UserQuota mobileView={false} />); | ||
expect(screen.getByText(`It seems that all available space is full`)).toBeVisible(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters