mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-15 09:13:16 +01:00
Always show the create goal button and open the upgrade modal when the goal limit is reached
This commit is contained in:
43
resources/js/Components/Common/Goal/GoalCreateButton.test.ts
Normal file
43
resources/js/Components/Common/Goal/GoalCreateButton.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import GoalCreateButton from './GoalCreateButton.vue';
|
||||
|
||||
function mountGoalCreateButton(canCreateMoreGoals: boolean) {
|
||||
return mount(GoalCreateButton, {
|
||||
props: { canCreateMoreGoals },
|
||||
slots: { default: 'Create your first goal' },
|
||||
global: {
|
||||
stubs: {
|
||||
GoalCreateModal: { name: 'GoalCreateModal', props: ['show'], template: '<div />' },
|
||||
UpgradeModal: {
|
||||
name: 'UpgradeModal',
|
||||
props: ['show', 'feature'],
|
||||
template: '<div />',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
describe('GoalCreateButton', () => {
|
||||
it('opens the create modal while more goals can be created', async () => {
|
||||
const wrapper = mountGoalCreateButton(true);
|
||||
|
||||
await wrapper.get('button').trigger('click');
|
||||
|
||||
expect(wrapper.getComponent({ name: 'GoalCreateModal' }).props('show')).toBe(true);
|
||||
expect(wrapper.getComponent({ name: 'UpgradeModal' }).props('show')).toBe(false);
|
||||
});
|
||||
|
||||
it('opens the upgrade modal once the goal limit is reached', async () => {
|
||||
const wrapper = mountGoalCreateButton(false);
|
||||
|
||||
expect(wrapper.get('button').text()).toBe('Create your first goal');
|
||||
await wrapper.get('button').trigger('click');
|
||||
|
||||
const upgradeModal = wrapper.getComponent({ name: 'UpgradeModal' });
|
||||
expect(upgradeModal.props('show')).toBe(true);
|
||||
expect(upgradeModal.props('feature')).toBe('goals');
|
||||
expect(wrapper.getComponent({ name: 'GoalCreateModal' }).props('show')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user