-
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.
feat: add workspace tests, chore: update router
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
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
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,61 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { mount, RouterLinkStub } from '@vue/test-utils'; | ||
import WorkSpace from '../WorkSpace.vue'; | ||
import i18n from '@/shared/lib/i18n'; | ||
import { RouteNames } from '@/shared/config/consts'; | ||
import { h } from 'vue'; | ||
import { SquareDashedKanban } from 'lucide-vue-next'; | ||
import { useRoute } from 'vue-router'; | ||
|
||
vi.mock('vue-router'); | ||
|
||
vi.mock('@vueuse/integrations/useCookies', () => { | ||
return { | ||
useCookies: () => ({ | ||
get(key: string) { | ||
return key === 'i18n' ? 'en-US' : undefined; | ||
} | ||
}) | ||
}; | ||
}); | ||
|
||
describe('tests for WorkSpace.vue', () => { | ||
//@ts-expect-error mock types | ||
useRoute.mockReturnValue({ | ||
name: RouteNames.boards | ||
}); | ||
const wrapper = mount(WorkSpace, { | ||
global: { | ||
plugins: [i18n], | ||
mocks: { | ||
t: (key: string) => { | ||
const translations: Record<string, string> = { | ||
'sidebar.boards': 'boards', | ||
'sidebar.section': 'workspace' | ||
}; | ||
return translations[key]; | ||
} | ||
}, | ||
stubs: { | ||
RouterLink: RouterLinkStub | ||
}, | ||
directives: { | ||
tooltip() {} | ||
} | ||
}, | ||
props: { | ||
isExpanded: true, | ||
links: [{ id: 0, title: 'boards', pathName: RouteNames.boards, icon: h(SquareDashedKanban) }] | ||
} | ||
}); | ||
|
||
it('should be render correctly', () => { | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should be redirect with RouterLink correctly', () => { | ||
expect(wrapper.findComponent(RouterLinkStub).props('to')).toEqual({ | ||
name: RouteNames.boards | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/widgets/layout/ui/sidebar/__tests__/__snapshots__/WorkSpace.spec.ts.snap
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,22 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`tests for WorkSpace.vue > should be render correctly 1`] = ` | ||
"<p class="name_block text-sm">workspace</p> | ||
<div class="sidebar_main_links"><a class="link"><button class="text-sm button secondary md link_btn"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="rgb(82 82 91 / 0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-dashed-kanban-icon"> | ||
<path d="M8 7v7"></path> | ||
<path d="M12 7v4"></path> | ||
<path d="M16 7v9"></path> | ||
<path d="M5 3a2 2 0 0 0-2 2"></path> | ||
<path d="M9 3h1"></path> | ||
<path d="M14 3h1"></path> | ||
<path d="M19 3a2 2 0 0 1 2 2"></path> | ||
<path d="M21 9v1"></path> | ||
<path d="M21 14v1"></path> | ||
<path d="M21 19a2 2 0 0 1-2 2"></path> | ||
<path d="M14 21h1"></path> | ||
<path d="M9 21h1"></path> | ||
<path d="M5 21a2 2 0 0 1-2-2"></path> | ||
<path d="M3 14v1"></path> | ||
<path d="M3 9v1"></path> | ||
</svg><span class="text-sm">boards</span></button></a></div>" | ||
`; |