Skip to content

Commit

Permalink
release: v0.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
cloydlau committed Apr 10, 2024
1 parent b21aad6 commit a12a128
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloydlau/json-editor-vue",
"version": "0.13.1",
"version": "0.13.2",
"exports": "./dist/json-editor-vue.mjs",
"publish": {
"include": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json-editor-vue",
"PascalCasedName": "JsonEditorVue",
"version": "0.13.1",
"version": "0.13.2",
"private": false,
"description": "Vue 2.6/2.7/3 & Nuxt 2/3 isomorphic JSON editor, viewer, formatter and validator.",
"author": {
Expand Down
29 changes: 24 additions & 5 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,43 @@ import { mount } from '@vue/test-utils'
import { expect, it } from 'vitest'
import JsonEditorVue from '../src/index'

it('string value in text mode', async () => {
it('text mode', async () => {
const wrapper = mount(JsonEditorVue, {
props: {
mode: 'text',
modelValue: '',
},
})
await wrapper.setProps({ modelValue: 'abc' })
expect(wrapper.vm.jsonEditor.get().json).toEqual('abc')

await wrapper.setProps({ modelValue: '123' })
await nextTick()
expect(wrapper.vm.jsonEditor.get().text).toEqual('123')

await wrapper.setProps({ modelValue: JSON.stringify({ a: 1 }) })
await nextTick()
expect(wrapper.vm.jsonEditor.get().text).toEqual(JSON.stringify({ a: 1 }))

await wrapper.setProps({ modelValue: { a: 1 } })
await nextTick()
expect(wrapper.vm.jsonEditor.get().json).toEqual({ a: 1 })
})

it('string value in tree mode', async () => {
it('tree mode', async () => {
const wrapper = mount(JsonEditorVue, {
props: {
modelValue: null,
},
})

await wrapper.setProps({ modelValue: '123' })
await nextTick()
expect(wrapper.vm.jsonEditor.get().text).toEqual('123')

await wrapper.setProps({ modelValue: JSON.stringify({ a: 1 }) })
await nextTick()
expect(wrapper.vm.jsonEditor.get().json).toEqual(JSON.stringify({ a: 1 }))
expect(wrapper.vm.jsonEditor.get().text).toEqual(JSON.stringify({ a: 1 }))

await wrapper.setProps({ modelValue: { a: 1 } })
await nextTick()
expect(wrapper.vm.jsonEditor.get().json).toEqual({ a: 1 })
})

0 comments on commit a12a128

Please sign in to comment.