Skip to content

Commit

Permalink
✅ test: update Snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Nov 29, 2018
1 parent 55b6733 commit 8df3773
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 119 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"vue": "*"
},
"devDependencies": {
"@vue/server-test-utils": "^1.0.0-beta.26",
"@vue/test-utils": "^1.0.0-beta.18",
"@vuedoc/md": "^1.5.0",
"autoprefixer": "^8.5.2",
Expand Down
74 changes: 8 additions & 66 deletions test/__snapshots__/complex.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,19 @@ exports[`Component Snapshot 1`] = `
<div>
<h1>Newsletter Subscription</h1>
<p>Sign up for free newsletters and get more delivered to your inbox</p>
<form>
<label placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"><span data-required-field="true">Full Name</span>
<input placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"
value="">
</label>
<label type="email" placeholder="Your Email" title="Please enter your email" label="Email" description="" required="required" name="email" maxlength="120"><span data-required-field="true">Email</span>
<input type="email" placeholder="Your Email" title="Please enter your email" label="Email" description="" required="required" name="email" maxlength="120" value="">
</label>
<form><label placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"><span data-required-field="true">Full Name</span><input placeholder="Your Full Name" title="Please enter your full name" type="text" value="" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"></label><label type="email" placeholder="Your Email" title="Please enter your email" label="Email" description="" required="required" name="email" maxlength="120"><span data-required-field="true">Email</span><input type="email" placeholder="Your Email" title="Please enter your email" value="" label="Email" description="" required="required" name="email" maxlength="120"></label>
<div class="sub">
<div class="sub-title">SubTitle</div>
<label placeholder="Sub Full Name" title="Please enter your full name" type="text" label="SubName" description="" name="sub.sName" minlength="8" maxlength="80"><span data-required-field="false">SubName</span>
<input placeholder="Sub Full Name" title="Please enter your full name" type="text" label="SubName" description="" name="sub.sName" minlength="8" maxlength="80" value="">
</label>
<label type="url" label="SubUrl" description="" name="sub.sUrl"><span data-required-field="false">SubUrl</span>
<input type="url" label="SubUrl" description="" name="sub.sUrl" value="">
</label>
<div class="sub-title">SubTitle</div><label placeholder="Sub Full Name" title="Please enter your full name" type="text" label="SubName" description="" name="sub.sName" minlength="8" maxlength="80"><span data-required-field="false">SubName</span><input placeholder="Sub Full Name" title="Please enter your full name" type="text" value="" label="SubName" description="" name="sub.sName" minlength="8" maxlength="80"></label><label type="url" label="SubUrl" description="" name="sub.sUrl"><span data-required-field="false">SubUrl</span><input type="url" value="" label="SubUrl" description="" name="sub.sUrl"></label>
<div class="sub">
<div class="sub-title">Sub2Title</div>
<label type="text" pattern="*" label="Sub2Name" description="" required="required" name="sub.sub2.sName2"><span data-required-field="true">Sub2Name</span>
<input type="text" pattern="*" label="Sub2Name" description="" required="required" name="sub.sub2.sName2" value="">
</label>
<label type="email" label="Sub2Email" description="" name="sub.sub2.sEmail2"><span data-required-field="false">Sub2Email</span>
<input type="email" label="Sub2Email" description="" name="sub.sub2.sEmail2" value="">
</label>
<label type="number" schemaType="integer" label="Sub2Age" description="" name="sub.sub2.sAge"><span data-required-field="false">Sub2Age</span>
<input type="number" schemaType="integer" label="Sub2Age" description="" name="sub.sub2.sAge" value="">
</label>
<div class="sub-title">Sub2Title</div><label type="text" pattern="*" label="Sub2Name" description="" required="required" name="sub.sub2.sName2"><span data-required-field="true">Sub2Name</span><input type="text" pattern="*" value="" label="Sub2Name" description="" required="required" name="sub.sub2.sName2"></label><label type="email" label="Sub2Email" description="" name="sub.sub2.sEmail2"><span data-required-field="false">Sub2Email</span><input type="email" value="" label="Sub2Email" description="" name="sub.sub2.sEmail2"></label><label type="number" schemaType="integer" label="Sub2Age" description="" name="sub.sub2.sAge"><span data-required-field="false">Sub2Age</span><input type="number" value="" schemaType="integer" label="Sub2Age" description="" name="sub.sub2.sAge"></label>
</div>
</div>
<label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select"><span data-required-field="true">List</span>
<select placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]"
type="select" value="">
</div><label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select"><span data-required-field="true">List</span><select placeholder="Select your list subscription" title="Please select your list subscription" value="" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select">
<option value="Daily New">Daily New</option>
<option value="Promotion">Promotion</option>
</select>
</label>
<label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="array" label="List2" description="" name="lists2" items="[object Object],[object Object]" type="checkbox"><span data-required-field="false">List2</span>
<div placeholder="Select your list subscription" title="Please select your list subscription" schemaType="array" label="List2" description="" name="lists2" items="[object Object],[object Object]" type="checkbox"
value="">
<input value="daily" label="Daily New">
<input value="promotion" label="Promotion">
</div>
</label>
<label schemaType="array" label="List3" description="" name="lists3" items="[object Object],[object Object]" type="radio"><span data-required-field="false">List3</span>
<div schemaType="array" label="List3" description="" name="lists3" items="[object Object],[object Object]" type="radio" value="">
<input value="daily" label="Daily New">
<input value="promotion" label="Promotion">
</div>
</label>
<label schemaType="array" label="List4" description="" name="lists4" items="" type="array"><span data-required-field="false">List4</span>
<div schemaType="array" label="List4" description="" name="lists4" items="" type="array" value=""></div>
</label>
<label type="textarea" placeholder="How did you hear about us?" schemaType="string" label="Source" description="Ex. Using the NPM Search Engine" name="source" maxlength="120"><span data-required-field="false">Source</span>
<textarea type="textarea" placeholder="How did you hear about us?" schemaType="string" label="Source" description="Ex. Using the NPM Search Engine" name="source" maxlength="120" value=""></textarea>
<br>
<small>Ex. Using the NPM Search Engine</small>
</label>
<label type="rate" allow-half="true" schemaType="number" label="Rate" description="" name="rate"><span data-required-field="false">Rate</span>
<input type="rate" allow-half="true" schemaType="number" label="Rate" description="" name="rate" value="2">
</label>
<label type="color" schemaType="string" label="Color" description="" name="color"><span data-required-field="false">Color</span>
<input type="color" schemaType="string" label="Color" description="" name="color" value="#409EFF">
</label>
<label type="switch" schemaType="boolean" label="Agree" description="You agree to receive occasional updates and special offers for vue-json-schema updates." name="agree"><span data-required-field="false">Agree</span>
<input type="switch" schemaType="boolean" label="Agree" description="You agree to receive occasional updates and special offers for vue-json-schema updates." name="agree">
<br>
<small>You agree to receive occasional updates and special offers for vue-json-schema updates.</small>
</label>
<label>
<button type="submit" label="Submit">Submit</button>
</label>
</select></label><label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="array" label="List2" description="" name="lists2" items="[object Object],[object Object]" type="checkbox"><span data-required-field="false">List2</span>
<div placeholder="Select your list subscription" title="Please select your list subscription" value="" schemaType="array" label="List2" description="" name="lists2" items="[object Object],[object Object]" type="checkbox"><input value="daily" label="Daily New"><input value="promotion" label="Promotion"></div></label><label schemaType="array" label="List3" description="" name="lists3" items="[object Object],[object Object]" type="radio"><span data-required-field="false">List3</span>
<div value="" schemaType="array" label="List3" description="" name="lists3" items="[object Object],[object Object]" type="radio"><input value="daily" label="Daily New"><input value="promotion" label="Promotion"></div></label><label schemaType="array" label="List4" description="" name="lists4" items="" type="array"><span data-required-field="false">List4</span>
<div value="" schemaType="array" label="List4" description="" name="lists4" items="" type="array"></div></label><label type="textarea" placeholder="How did you hear about us?" schemaType="string" label="Source" description="Ex. Using the NPM Search Engine" name="source" maxlength="120"><span data-required-field="false">Source</span><textarea type="textarea" placeholder="How did you hear about us?" value="" schemaType="string" label="Source" description="Ex. Using the NPM Search Engine" name="source" maxlength="120"></textarea><br><small>Ex. Using the NPM Search Engine</small></label><label type="rate" allow-half="true" schemaType="number" label="Rate" description="" name="rate"><span data-required-field="false">Rate</span><input type="rate" allow-half="true" value="2" schemaType="number" label="Rate" description="" name="rate"></label><label type="color" schemaType="string" label="Color" description="" name="color"><span data-required-field="false">Color</span><input type="color" value="#409EFF" schemaType="string" label="Color" description="" name="color"></label><label type="switch" schemaType="boolean" label="Agree" description="You agree to receive occasional updates and special offers for vue-json-schema updates." name="agree"><span data-required-field="false">Agree</span><input type="switch" schemaType="boolean" label="Agree" description="You agree to receive occasional updates and special offers for vue-json-schema updates." name="agree"><br><small>You agree to receive occasional updates and special offers for vue-json-schema updates.</small></label><label><button type="submit" label="Submit">Submit</button></label>
</form>
</div>
`;
12 changes: 1 addition & 11 deletions test/__snapshots__/schema.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@

exports[`schema Snapshot 1`] = `
<div>
<form>
<input placeholder="Your First and Second Name" type="text" schemaType="string" label="" description="" required="required" name="name" minlength="8" maxlength="80" value="">
<input placeholder="Enter your email" autoComplete="off" type="text" schemaType="string" label="" description="" required="required" name="email" minlength="8" maxlength="120" value="">
<input type="password" placeholder="Enter your password" autoComplete="off" schemaType="string" label="" description="" required="required" name="password" minlength="8" maxlength="120" value="">
<label schemaType="boolean" label="I accept the terms of use" description="" required="required" name="termsAccepted" type="checkbox"><span data-required-field="true">I accept the terms of use</span>
<input schemaType="boolean" label="I accept the terms of use" description="" required="required" name="termsAccepted" type="checkbox" value="">
</label>
<label>
<button type="submit" label="Submit">Submit</button>
</label>
</form>
<form><input placeholder="Your First and Second Name" name="name" minlength="8" maxlength="80" type="text" value="" schemaType="string" label="" description="" required="required"><input placeholder="Enter your email" autoComplete="off" name="email" minlength="8" maxlength="120" type="text" value="" schemaType="string" label="" description="" required="required"><input type="password" placeholder="Enter your password" autoComplete="off" name="password" minlength="8" maxlength="120" value="" schemaType="string" label="" description="" required="required"><label name="termsAccepted" type="checkbox" schemaType="boolean" label="I accept the terms of use" description="" required="required"><span data-required-field="true">I accept the terms of use</span><input name="termsAccepted" type="checkbox" value="" schemaType="boolean" label="I accept the terms of use" description="" required="required"></label><label><button type="submit" label="Submit">Submit</button></label></form>
</div>
`;
19 changes: 2 additions & 17 deletions test/__snapshots__/simple.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@ exports[`Component Snapshot 1`] = `
<div>
<h1>Newsletter Subscription</h1>
<p>Sign up for free newsletters and get more delivered to your inbox</p>
<form>
<label placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"><span data-required-field="true">Full Name</span>
<input placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"
value="">
</label>
<label type="email" placeholder="Your Email" title="Please enter your email" schemaType="string" label="Email" description="" required="required" name="email" maxlength="120"><span data-required-field="true">Email</span>
<input type="email" placeholder="Your Email" title="Please enter your email" schemaType="string" label="Email" description="" required="required" name="email" maxlength="120" value="">
</label>
<label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select"><span data-required-field="true">List</span>
<select placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]"
type="select" value="">
<form><label placeholder="Your Full Name" title="Please enter your full name" type="text" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"><span data-required-field="true">Full Name</span><input placeholder="Your Full Name" title="Please enter your full name" type="text" value="" schemaType="string" label="Full Name" description="" required="required" name="name" minlength="8" maxlength="80"></label><label type="email" placeholder="Your Email" title="Please enter your email" schemaType="string" label="Email" description="" required="required" name="email" maxlength="120"><span data-required-field="true">Email</span><input type="email" placeholder="Your Email" title="Please enter your email" value="" schemaType="string" label="Email" description="" required="required" name="email" maxlength="120"></label><label placeholder="Select your list subscription" title="Please select your list subscription" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select"><span data-required-field="true">List</span><select placeholder="Select your list subscription" title="Please select your list subscription" value="" schemaType="string" label="List" description="" required="required" name="lists" items="[object Object],[object Object]" type="select">
<option value="Daily New">Daily New</option>
<option value="Promotion">Promotion</option>
</select>
</label>
<label>
<button type="submit" label="Submit">Submit</button>
</label>
</form>
</select></label><label><button type="submit" label="Submit">Submit</button></label></form>
</div>
`;
13 changes: 4 additions & 9 deletions test/complex.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { shallowMount } from '@vue/test-utils';
import { createRenderer } from 'vue-server-renderer';
import { renderToString } from '@vue/server-test-utils';

const packPath = process.env.TEST_LIB ? '../lib/json-editor.min.js' : '../src/JsonEditor.vue';
const pack = require(packPath);
Expand All @@ -17,16 +17,11 @@ describe('Component', () => {
expect(wrapper.isVueInstance()).toBeTruthy();
});

it('Snapshot', done => {
const wrapper = shallowMount(JsonEditor, {
it('Snapshot', () => {
const renderedString = renderToString(JsonEditor, {
propsData: { schema },
});
const renderer = createRenderer();
renderer.renderToString(wrapper.vm, (err, str) => {
if (err) throw new Error(err);
expect(str).toMatchSnapshot();
done();
});
expect(renderedString).toMatchSnapshot();
});

});
12 changes: 5 additions & 7 deletions test/schema.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { shallowMount } from '@vue/test-utils';
import { createRenderer } from 'vue-server-renderer';
import { renderToString } from '@vue/server-test-utils';

const packPath = process.env.TEST_LIB ? '../lib/json-editor.min.js' : '../src/JsonEditor.vue';
const pack = require(packPath);
Expand Down Expand Up @@ -80,13 +80,11 @@ describe('schema', () => {
expect(button.innerHTML).toBe('Submit');
});

test('Snapshot', done => {
const renderer = createRenderer();
renderer.renderToString(wrapper.vm, (err, str) => {
if (err) throw new Error(err);
expect(str).toMatchSnapshot();
done();
test('Snapshot', () => {
const renderedString = renderToString(JsonEditor, {
propsData: { schema, value: model },
});
expect(renderedString).toMatchSnapshot();
});

});
13 changes: 4 additions & 9 deletions test/simple.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { shallowMount } from '@vue/test-utils';
import { createRenderer } from 'vue-server-renderer';
import { renderToString } from '@vue/server-test-utils';

const packPath = process.env.TEST_LIB ? '../lib/json-editor.min.js' : '../src/JsonEditor.vue';
const pack = require(packPath);
Expand All @@ -25,16 +25,11 @@ describe('Component', () => {
expect(wrapper.isVueInstance()).toBeTruthy();
});

it('Snapshot', done => {
const wrapper = shallowMount(JsonEditor, {
it('Snapshot', () => {
const renderedString = renderToString(JsonEditor, {
propsData: { schema },
});
const renderer = createRenderer();
renderer.renderToString(wrapper.vm, (err, str) => {
if (err) throw new Error(err);
expect(str).toMatchSnapshot();
done();
});
expect(renderedString).toMatchSnapshot();
});

describe('Mount with data and set data', () => {
Expand Down

0 comments on commit 8df3773

Please sign in to comment.