Skip to content

Commit

Permalink
🐛 Fix running validation more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Richard committed May 25, 2016
1 parent 22fcceb commit ae6ab61
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/form/validation.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

const b = require('browserify')();
const browserify = require('browserify');
const stream = require('stream');

// const util = require('../util');

const s = new stream.Readable();

const rendered = (type) => {
return new Promise((res, rej) => {
const b = browserify();
const s = new stream.Readable();

const validationFunctions = {};
const allSettings = {};
const inputs = {};
Expand Down
24 changes: 24 additions & 0 deletions tests/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,27 @@ test('Form Generation', t => {
t.is(typeof rendered.html, 'string', 'HTML is a string');
});
});

test('Form Generation, Again', t => {
return types.only('foo').then(result => {
return form(result);
}).then(rendered => {
t.true(rendered.hasOwnProperty('validation'), 'Validation JS generated');
t.true(rendered.hasOwnProperty('html'), 'HTML generated');

t.is(typeof rendered.validation, 'string', 'Validation is a string');
t.is(typeof rendered.html, 'string', 'HTML is a string');
});
});

test('Form Generation, Again Again', t => {
return types.only('bar').then(result => {
return form(result);
}).then(rendered => {
t.true(rendered.hasOwnProperty('validation'), 'Validation JS generated');
t.true(rendered.hasOwnProperty('html'), 'HTML generated');

t.is(typeof rendered.validation, 'string', 'Validation is a string');
t.is(typeof rendered.html, 'string', 'HTML is a string');
});
});

0 comments on commit ae6ab61

Please sign in to comment.