Skip to content

Commit d238719

Browse files
author
Dobromir Hristov
committed
refactor: extract title class to a constant
1 parent a4b144e commit d238719

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/components/DocumentationTopic/ContentTableSection.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import LinkableHeading from 'docc-render/components/ContentNode/LinkableHeading.vue';
3333
import { anchorize } from 'docc-render/utils/strings';
3434
35+
export const TITLE_CLASS_NAME = 'contenttable-title';
36+
3537
export default {
3638
name: 'ContentTableSection',
3739
components: { LinkableHeading },
@@ -47,7 +49,7 @@ export default {
4749
},
4850
computed: {
4951
anchorComputed: ({ title, anchor }) => anchor || anchorize(title),
50-
className: () => 'contenttable-title',
52+
className: () => TITLE_CLASS_NAME,
5153
},
5254
};
5355
</script>

tests/unit/components/DocumentationTopic/ContentTableSection.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010

1111
import { shallowMount } from '@vue/test-utils';
12-
import ContentTableSection from 'docc-render/components/DocumentationTopic/ContentTableSection.vue';
12+
import ContentTableSection, {
13+
TITLE_CLASS_NAME,
14+
} from 'docc-render/components/DocumentationTopic/ContentTableSection.vue';
1315

1416
const {
1517
LinkableHeading,
@@ -34,12 +36,12 @@ describe('ContentTableSection', () => {
3436
expect(title.exists()).toBe(true);
3537
expect(title.props('level')).toBe(3);
3638
expect(title.props('registerOnThisPage')).toBe(false);
37-
expect(title.classes()).toContain('contenttable-title');
39+
expect(title.classes()).toContain(TITLE_CLASS_NAME);
3840
expect(title.text()).toContain(propsData.title);
3941
});
4042

4143
it('renders an `id` if `anchor` is provided', () => {
42-
const title = wrapper.find('.title');
44+
const title = wrapper.find(`.${TITLE_CLASS_NAME}`);
4345
expect(title.attributes('id')).toBe(undefined);
4446
wrapper.setProps({
4547
anchor: 'foo-bar',
@@ -55,7 +57,7 @@ describe('ContentTableSection', () => {
5557
},
5658
});
5759
const div = wrapper.find('.section-title');
58-
const title = div.find('.contenttable-title');
60+
const title = div.find(`.${TITLE_CLASS_NAME}`);
5961
expect(title.text()).toEqual('Title Text');
6062
});
6163

0 commit comments

Comments
 (0)