mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
#122 add tests
This commit is contained in:
@@ -130,7 +130,6 @@ export default {
|
|||||||
try {
|
try {
|
||||||
this.formattedJson = JSON.stringify(JSON.parse(jsonStr), null, 4)
|
this.formattedJson = JSON.stringify(JSON.parse(jsonStr), null, 4)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
|
||||||
this.formattedJson = ''
|
this.formattedJson = ''
|
||||||
this.messages = [
|
this.messages = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import ValueViewer from '@/views/Main/Workspace/Tabs/Tab/RunResult/ValueViewer'
|
import ValueViewer from '@/views/Main/Workspace/Tabs/Tab/RunResult/ValueViewer.vue'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
|
|
||||||
describe('ValueViewer.vue', () => {
|
describe('ValueViewer.vue', () => {
|
||||||
@@ -8,7 +8,7 @@ describe('ValueViewer.vue', () => {
|
|||||||
sinon.restore()
|
sinon.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows value in text mode', async () => {
|
it('shows value in text mode', () => {
|
||||||
const wrapper = mount(ValueViewer, {
|
const wrapper = mount(ValueViewer, {
|
||||||
props: {
|
props: {
|
||||||
cellValue: 'foo'
|
cellValue: 'foo'
|
||||||
@@ -42,4 +42,45 @@ describe('ValueViewer.vue', () => {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('wraps lines', async () => {
|
||||||
|
const wrapper = mount(ValueViewer, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
cellValue: 'foo'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
wrapper.wrapperElement.parentElement.style.width = '50px'
|
||||||
|
const valueBody = wrapper.find('.value-body').wrapperElement
|
||||||
|
expect(valueBody.scrollWidth).to.equal(valueBody.clientWidth)
|
||||||
|
|
||||||
|
await wrapper.setProps({ cellValue: 'foo'.repeat(100) })
|
||||||
|
expect(valueBody.scrollWidth).not.to.equal(valueBody.clientWidth)
|
||||||
|
|
||||||
|
await wrapper.find('button.line-wrap').trigger('click')
|
||||||
|
expect(valueBody.scrollWidth).to.equal(valueBody.clientWidth)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('wraps lines in code mirror', async () => {
|
||||||
|
const wrapper = mount(ValueViewer, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: {
|
||||||
|
cellValue: '{"foo": "foofoofoofoofoofoofoofoofoofoo"}'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await wrapper.find('button.json').trigger('click')
|
||||||
|
|
||||||
|
wrapper.wrapperElement.parentElement.style.width = '50px'
|
||||||
|
const codeMirrorScroll = wrapper.find('.CodeMirror-scroll').wrapperElement
|
||||||
|
expect(codeMirrorScroll.scrollWidth).not.to.equal(
|
||||||
|
codeMirrorScroll.clientWidth
|
||||||
|
)
|
||||||
|
|
||||||
|
await wrapper.find('button.line-wrap').trigger('click')
|
||||||
|
expect(codeMirrorScroll.scrollWidth).to.equal(codeMirrorScroll.clientWidth)
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user