From 6de439598308b7086a2ae6730b00fc91c0d80f05 Mon Sep 17 00:00:00 2001 From: vittoriaThinkst <126554007+vittoriaThinkst@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:34:59 +0200 Subject: [PATCH] Update UI Card Token (#490) * Add token card button, fix test for code snippet * Remove consolelog on BaseCodeSnippet.spec.ts --- .../components/base/BaseCodeSnippet.spec.ts | 21 ++++- .../__snapshots__/BaseCopyButton.spec.ts.snap | 2 +- .../src/components/ui/CardToken.spec.ts | 3 +- frontend_vue/src/components/ui/CardToken.vue | 88 +++++++++---------- 4 files changed, 65 insertions(+), 49 deletions(-) diff --git a/frontend_vue/src/components/base/BaseCodeSnippet.spec.ts b/frontend_vue/src/components/base/BaseCodeSnippet.spec.ts index 3beafdc9b..74641b40e 100644 --- a/frontend_vue/src/components/base/BaseCodeSnippet.spec.ts +++ b/frontend_vue/src/components/base/BaseCodeSnippet.spec.ts @@ -1,5 +1,5 @@ import { mount } from '@vue/test-utils'; -import { vi } from 'vitest'; +import { vi, beforeEach } from 'vitest'; import BaseCodeSnippet from '@/components/base/BaseCodeSnippet.vue'; import BaseCopyButton from './BaseCopyButton.vue'; import BaseRefreshButton from './BaseRefreshButton.vue'; @@ -15,6 +15,17 @@ const tooltip = vi.fn(); library.add(faRotateRight, faCheck, faCopy); describe('BaseCodeSnippet', () => { + beforeEach(() => { + vi.mock('@highlightjs/vue-plugin', async () => { + const hljsVuePlugin = { + hljsVuePlugin: { + component: vi.fn(), + }, + }; + return { default: hljsVuePlugin }; + }); + }); + it('renders label when passed', () => { const label = 'Test Label'; const code = 'const example = () => { return "Hello World"; }'; @@ -23,14 +34,20 @@ describe('BaseCodeSnippet', () => { code: code, lang: 'javascript', showExpandButton: false, + label: label, }, global: { - stubs: { BaseCopyButton, BaseRefreshButton, FontAwesomeIcon }, + stubs: { + BaseCopyButton, + BaseRefreshButton, + FontAwesomeIcon, + }, }, directives: { tooltip, }, }); + expect(wrapper.text()).toMatch(label); }); diff --git a/frontend_vue/src/components/base/__snapshots__/BaseCopyButton.spec.ts.snap b/frontend_vue/src/components/base/__snapshots__/BaseCopyButton.spec.ts.snap index 17492b23c..268d86fcc 100644 --- a/frontend_vue/src/components/base/__snapshots__/BaseCopyButton.spec.ts.snap +++ b/frontend_vue/src/components/base/__snapshots__/BaseCopyButton.spec.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`BaseCopyButton > render correctly 1`] = ` -"