diff options
author | Sukanya Pandey <sukapan1@in.ibm.com> | 2021-01-05 08:58:36 +0300 |
---|---|---|
committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2021-01-07 01:02:28 +0300 |
commit | d348c44ddf715b6b3cc9bd5616f9bccf0295ba4e (patch) | |
tree | d81d85fa1f102bd7eee9831c15c9d97326ceb2be /tests/unit | |
parent | e881499e182bdb7030920c9dc81bfbf423ae620c (diff) | |
download | webui-vue-d348c44ddf715b6b3cc9bd5616f9bccf0295ba4e.tar.xz |
Add unit test cases for table toolbar component
Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com>
Change-Id: I2e93244fcd8bbde7c9398cf0db56d5125614aa69
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/Global/TableToolbar.spec.js | 27 | ||||
-rw-r--r-- | tests/unit/Global/__snapshots__/TableToolbar.spec.js.snap | 31 |
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/unit/Global/TableToolbar.spec.js b/tests/unit/Global/TableToolbar.spec.js new file mode 100644 index 00000000..fc2beacb --- /dev/null +++ b/tests/unit/Global/TableToolbar.spec.js @@ -0,0 +1,27 @@ +import { mount, createLocalVue } from '@vue/test-utils'; +import TableToolbar from '@/components/Global/TableToolbar'; +import BootstrapVue from 'bootstrap-vue'; + +const localVue = createLocalVue(); +localVue.use(BootstrapVue); +describe('TableToolbar.vue', () => { + const wrapper = mount(TableToolbar, { + localVue, + propsData: { + selectedItemsCount: 0, + }, + mocks: { + $t: (key) => key, + }, + }); + it('should exist', () => { + expect(wrapper.exists()).toBe(true); + }); + it('should render class toolbar-container when selectedItemsCount is greater than 0', async () => { + await wrapper.setProps({ selectedItemsCount: 12 }); + expect(wrapper.find('.toolbar-container').exists()).toBe(true); + }); + it('should render correctly', () => { + expect(wrapper.element).toMatchSnapshot(); + }); +}); diff --git a/tests/unit/Global/__snapshots__/TableToolbar.spec.js.snap b/tests/unit/Global/__snapshots__/TableToolbar.spec.js.snap new file mode 100644 index 00000000..140f6f42 --- /dev/null +++ b/tests/unit/Global/__snapshots__/TableToolbar.spec.js.snap @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TableToolbar.vue should render correctly 1`] = ` +<transition-stub + name="slide" +> + <div + class="toolbar-container" + > + <div + class="toolbar-content" + > + <p + class="toolbar-selected" + > + 12 global.action.selected + </p> + <div + class="toolbar-actions d-flex" + > + <button + class="btn d-block btn-secondary" + type="button" + > + global.action.cancel + </button> + </div> + </div> + </div> +</transition-stub> +`; |