-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactored NCI-SECTION component, extracting the createComponent function into its own Vue component named NCI-COMPONENT. - Created basic unit test for NCI-COMPONENT [Ticket: NCI-13]
- Loading branch information
1 parent
02d6dba
commit 4dd8fd1
Showing
3 changed files
with
70 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { mount } from '@vue/test-utils' | ||
import nciComponent from '@/nci/app/components/nci-component/index.vue' | ||
import { Button } from '@/nci/app/interfaces'; | ||
|
||
/** NCI-COMPONENT Tests */ | ||
/** | ||
* Pass a component definition and get a rendered component back. | ||
* @test Check the component loads | ||
*/ | ||
describe('nci-anchor component', () => { | ||
|
||
test('Successfully loads a button.', () => { | ||
|
||
let wrapper = mount(nciComponent, { | ||
propsData: { | ||
component: { | ||
type: "title", | ||
title: "Contact Us", | ||
href: "https://www.nuxt.org", | ||
size: "md", | ||
color: "primary", | ||
styles: "w-auto bg-gray-200" | ||
} as Button | ||
}, | ||
}) | ||
/** Check the component mounted */ | ||
expect(wrapper.vm).toBeTruthy(); | ||
|
||
}); | ||
}) |
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,28 @@ | ||
<script lang="ts"> | ||
/** Import utilities from Vue3 Composition API */ | ||
import { defineComponent, PropType, h } from "@nuxtjs/composition-api"; | ||
/** NCI-COMPONENT COMPONENT */ | ||
/** | ||
* Setup the component | ||
* @function nciComponent | ||
* @param {object} component Definition of a component | ||
*/ | ||
const nciComponent = defineComponent({ | ||
name: "nci-component", | ||
props: { | ||
component: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
setup(props) { | ||
return () => | ||
h("nci-" + props.component.type, { | ||
props: { ...props.component }, | ||
}); | ||
}, | ||
}); | ||
export default nciComponent; | ||
</script> |
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