From dcf63edaf7a926e63e178b6eeb67cadeb1dbf8e3 Mon Sep 17 00:00:00 2001 From: Marcus Ortiz Date: Wed, 27 Mar 2024 13:41:53 -0700 Subject: [PATCH] Support thematic breaks (#791) Add support for "thematic breaks" using `
`. Resolves: rdar://125507297 --- src/components/ContentNode.vue | 6 ++++- src/components/ContentNode/ThematicBreak.vue | 23 +++++++++++++++++++ tests/unit/components/ContentNode.spec.js | 11 ++++++++- .../ContentNode/ThematicBreak.spec.js | 20 ++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/components/ContentNode/ThematicBreak.vue create mode 100644 tests/unit/components/ContentNode/ThematicBreak.spec.js diff --git a/src/components/ContentNode.vue b/src/components/ContentNode.vue index 17807d9a1..fd9bab5a4 100644 --- a/src/components/ContentNode.vue +++ b/src/components/ContentNode.vue @@ -1,7 +1,7 @@ + + + diff --git a/tests/unit/components/ContentNode.spec.js b/tests/unit/components/ContentNode.spec.js index ced84b1b3..337bd3e19 100644 --- a/tests/unit/components/ContentNode.spec.js +++ b/tests/unit/components/ContentNode.spec.js @@ -1,7 +1,7 @@ /** * This source file is part of the Swift.org open source project * - * Copyright (c) 2021-2023 Apple Inc. and the Swift project authors + * Copyright (c) 2021-2024 Apple Inc. and the Swift project authors * Licensed under Apache License v2.0 with Runtime Library Exception * * See https://swift.org/LICENSE.txt for license information @@ -31,6 +31,7 @@ import TaskList from 'docc-render/components/ContentNode/TaskList.vue'; import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle'; import LinksBlock from '@/components/ContentNode/LinksBlock.vue'; import DeviceFrame from '@/components/ContentNode/DeviceFrame.vue'; +import ThematicBreak from 'docc-render/components/ContentNode/ThematicBreak.vue'; const { TableHeaderStyle, TableColumnAlignments } = ContentNode.constants; @@ -1820,6 +1821,14 @@ describe('ContentNode', () => { }); }); + describe('with type="thematicBreak"', () => { + it('renders a `ThematicBreak`', () => { + const wrapper = mountWithItem({ type: ContentNode.BlockType.thematicBreak }); + const tbreak = wrapper.find(ThematicBreak); + expect(tbreak.exists()).toBe(true); + }); + }); + describe('with type="superscript"', () => { it('renders superscript tag', () => { const wrapper = mountWithItem({ diff --git a/tests/unit/components/ContentNode/ThematicBreak.spec.js b/tests/unit/components/ContentNode/ThematicBreak.spec.js new file mode 100644 index 000000000..98f794c93 --- /dev/null +++ b/tests/unit/components/ContentNode/ThematicBreak.spec.js @@ -0,0 +1,20 @@ +/** + * This source file is part of the Swift.org open source project + * + * Copyright (c) 2024 Apple Inc. and the Swift project authors + * Licensed under Apache License v2.0 with Runtime Library Exception + * + * See https://swift.org/LICENSE.txt for license information + * See https://swift.org/CONTRIBUTORS.txt for Swift project authors +*/ +import { shallowMount } from '@vue/test-utils'; +import ThematicBreak from 'docc-render/components/ContentNode/ThematicBreak.vue'; + +describe('ThematicBreak', () => { + it('renders an
element', () => { + const wrapper = shallowMount(ThematicBreak); + const hr = wrapper.find('hr'); + expect(hr.exists()).toBe(true); + expect(hr.classes('thematic-break')).toBe(true); + }); +});