factorial-form
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -6,2 +6,3 @@ import { Form } from '../src' | ||
name: 'paco', | ||
active: true, | ||
age: 0, | ||
@@ -19,2 +20,3 @@ price: 0, | ||
price: 'cents', | ||
active: 'boolean', | ||
country_metadata: { | ||
@@ -63,2 +65,3 @@ social_security: 'string' | ||
name: 'paco', | ||
active: true, | ||
age: '0', | ||
@@ -79,2 +82,34 @@ price: '0', | ||
describe('when a boolean field is missing', () => { | ||
beforeEach(() => { | ||
const newAttr = { | ||
id: 1, | ||
name: 'paco', | ||
age: 0, | ||
price: 0, | ||
country_metadata: { | ||
social_security: '1234' | ||
} | ||
} | ||
form = new Form(newAttr, types) | ||
}) | ||
it('returns false', () => { | ||
expect(form.isComplete).toBe(false) | ||
}) | ||
}) | ||
describe('when a boolean field is empty', () => { | ||
beforeEach(() => form.setValues({active: ''})) | ||
it('returns false', () => { | ||
expect(form.isComplete).toBe(false) | ||
}) | ||
}) | ||
describe('when a boolean field is null', () => { | ||
beforeEach(() => form.setValues({active: null})) | ||
it('returns false', () => { | ||
expect(form.isComplete).toBe(false) | ||
}) | ||
}) | ||
describe('when all fields are complete', () => { | ||
@@ -81,0 +116,0 @@ beforeEach(() => form.setValues({age: 0})) |
@@ -294,5 +294,5 @@ 'use strict'; | ||
case 'number': | ||
case 'cents': | ||
case 'boolean': | ||
case 'cents': | ||
return _lodash2.default.isNull(field.value); | ||
return field.value === '' || _lodash2.default.isNull(field.value); | ||
default: | ||
@@ -299,0 +299,0 @@ return !field.value; |
{ | ||
"name": "factorial-form", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Factorial form library", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
495991
62
6585
0