-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
189 additions
and
39 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,100 @@ | ||
import Component from './index'; | ||
|
||
describe('QPopover', () => { | ||
const options = { | ||
slots: { | ||
reference: '<button>Open</button>' | ||
} | ||
}; | ||
|
||
it('should match snapshot', () => { | ||
const { element } = shallowMount(Component, options); | ||
expect(element).toMatchSnapshot(); | ||
}); | ||
|
||
it('data should match snapshot', () => { | ||
expect(Component.data()).toMatchSnapshot(); | ||
}); | ||
|
||
describe('computed', () => { | ||
describe('popoverClasses', () => { | ||
it('should return expected value if icon does not exist', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setProps({ | ||
icon: '' | ||
}); | ||
const expected = { | ||
'q-popover_without-icon': true | ||
}; | ||
expect(instance.vm.popoverClasses).toEqual(expected); | ||
}); | ||
|
||
it('should return expected value if icon exists', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setProps({ | ||
icon: 'icon-name' | ||
}); | ||
const expected = { | ||
'q-popover_without-icon': false | ||
}; | ||
expect(instance.vm.popoverClasses).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('methods', () => { | ||
describe('togglePopover', () => { | ||
it('should set isPopoverShown to false', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setData({ | ||
isPopoverShown: true | ||
}); | ||
instance.vm.togglePopover(); | ||
expect(instance.vm.isPopoverShown).toBeFalsy(); | ||
}); | ||
|
||
it('should set isPopoverShown to true', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setData({ | ||
isPopoverShown: false | ||
}); | ||
instance.vm.togglePopover(); | ||
expect(instance.vm.isPopoverShown).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('destroy', () => { | ||
it('should set isPopoverShown to false', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setData({ | ||
isPopoverShown: true | ||
}); | ||
instance.vm.destroy(); | ||
expect(instance.vm.isPopoverShown).toBeFalsy(); | ||
}); | ||
|
||
it('should call destroy', () => { | ||
const instance = shallowMount(Component, options); | ||
const spy = jest.fn(() => {}); | ||
instance.setData({ | ||
popperJS: { | ||
destroy: spy | ||
} | ||
}); | ||
instance.vm.destroy(); | ||
expect(spy).toBeCalled(); | ||
}); | ||
|
||
it('should set popperJS to null', () => { | ||
const instance = shallowMount(Component, options); | ||
instance.setData({ | ||
popperJS: { | ||
destroy: () => {} | ||
} | ||
}); | ||
instance.vm.destroy(); | ||
expect(instance.vm.popperJS).toBeNull(); | ||
}); | ||
}); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
src/qComponents/QPopover/__snapshots__/QPopover.test.js.snap
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,40 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`QPopover data should match snapshot 1`] = ` | ||
Object { | ||
"isPopoverShown": false, | ||
"popperJS": null, | ||
"referenceElement": null, | ||
"zIndex": null, | ||
} | ||
`; | ||
|
||
exports[`QPopover should match snapshot 1`] = ` | ||
<span> | ||
<transition-stub | ||
name="fade-in-linear" | ||
> | ||
<div | ||
class="q-popover q-popover_without-icon" | ||
style="display: none;" | ||
> | ||
<!----> | ||
<q-scrollbar-stub | ||
theme="primary" | ||
viewclass="scrollbar__list" | ||
viewtag="div" | ||
wrapclass="q-popover__inner" | ||
> | ||
<!----> | ||
<!----> | ||
</q-scrollbar-stub> | ||
</div> | ||
</transition-stub> | ||
<button> | ||
Open | ||
</button> | ||
</span> | ||
`; |
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,29 @@ | ||
import Component from './index'; | ||
|
||
describe('QTable', () => { | ||
const options = { | ||
propsData: { | ||
groupsOfColumns: [ | ||
{ | ||
columns: [ | ||
{ | ||
key: 'col1', | ||
value: 'Column 1' | ||
} | ||
] | ||
} | ||
], | ||
rows: [ | ||
{ | ||
col1: 'Columns row 1' | ||
} | ||
] | ||
} | ||
}; | ||
|
||
it('QTable should match snapshot', () => { | ||
const { element } = shallowMount(Component, options); | ||
|
||
expect(element).toMatchSnapshot(); | ||
}); | ||
}); |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import Vue from 'vue'; | ||
import { mount, shallowMount } from '@vue/test-utils'; | ||
import { QScrollbar } from '../../src/qComponents'; | ||
|
||
Vue.use(QScrollbar); | ||
|
||
global.mount = mount; | ||
global.shallowMount = shallowMount; |