summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/global/MkMfm.stories.impl.ts
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2024-09-17 17:03:09 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2024-09-17 17:03:09 +0900
commitcacdf9d9392ccdf960452c9fec03fb7dc7c679e2 (patch)
tree7fdb6da2713ec604cd33e5502c0d4e8adb959dab /packages/frontend/src/components/global/MkMfm.stories.impl.ts
parentrefactor (diff)
downloadmisskey-cacdf9d9392ccdf960452c9fec03fb7dc7c679e2.tar.gz
misskey-cacdf9d9392ccdf960452c9fec03fb7dc7c679e2.tar.bz2
misskey-cacdf9d9392ccdf960452c9fec03fb7dc7c679e2.zip
refactor
MkMisskeyFlavoredMarkdown -> MkMfm
Diffstat (limited to 'packages/frontend/src/components/global/MkMfm.stories.impl.ts')
-rw-r--r--packages/frontend/src/components/global/MkMfm.stories.impl.ts77
1 files changed, 77 insertions, 0 deletions
diff --git a/packages/frontend/src/components/global/MkMfm.stories.impl.ts b/packages/frontend/src/components/global/MkMfm.stories.impl.ts
new file mode 100644
index 0000000000..1daf7a29cb
--- /dev/null
+++ b/packages/frontend/src/components/global/MkMfm.stories.impl.ts
@@ -0,0 +1,77 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { StoryObj } from '@storybook/vue3';
+import { expect, within } from '@storybook/test';
+import MkMfm from './MkMfm.js';
+export const Default = {
+ render(args) {
+ return {
+ components: {
+ MkMfm,
+ },
+ setup() {
+ return {
+ args,
+ };
+ },
+ computed: {
+ props() {
+ return {
+ ...this.args,
+ };
+ },
+ },
+ template: '<MkMfm v-bind="props" />',
+ };
+ },
+ async play({ canvasElement, args }) {
+ const canvas = within(canvasElement);
+ if (args.plain) {
+ const aiHelloMiskist = canvas.getByText('@ai *Hello*, #Miskist!');
+ await expect(aiHelloMiskist).toBeInTheDocument();
+ } else {
+ const ai = canvas.getByText('@ai');
+ await expect(ai).toBeInTheDocument();
+ await expect(ai.closest('a')).toHaveAttribute('href', '/@ai');
+ const hello = canvas.getByText('Hello');
+ await expect(hello).toBeInTheDocument();
+ await expect(hello.style.fontStyle).toBe('oblique');
+ const miskist = canvas.getByText('#Miskist');
+ await expect(miskist).toBeInTheDocument();
+ await expect(miskist).toHaveAttribute('href', args.isNote ?? true ? '/tags/Miskist' : '/user-tags/Miskist');
+ }
+ const heart = canvas.getByAltText('❤');
+ await expect(heart).toBeInTheDocument();
+ await expect(heart).toHaveAttribute('src', '/twemoji/2764.svg');
+ },
+ args: {
+ text: '@ai *Hello*, #Miskist! ❤',
+ },
+ parameters: {
+ layout: 'centered',
+ },
+} satisfies StoryObj<typeof MkMfm>;
+export const Plain = {
+ ...Default,
+ args: {
+ ...Default.args,
+ plain: true,
+ },
+} satisfies StoryObj<typeof MkMfm>;
+export const Nowrap = {
+ ...Default,
+ args: {
+ ...Default.args,
+ nowrap: true,
+ },
+} satisfies StoryObj<typeof MkMfm>;
+export const IsNotNote = {
+ ...Default,
+ args: {
+ ...Default.args,
+ isNote: false,
+ },
+} satisfies StoryObj<typeof MkMfm>;