Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hmcts/one-per-page

Package Overview
Dependencies
Maintainers
14
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hmcts/one-per-page - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

7

CHANGELOG.md

@@ -0,1 +1,8 @@

<a name="3.1.2"></a>
## 3.1.2 (2018-03-07)
* Ensure forms filled from temp values are validated on GET requests ([093509f](https://github.com/hmcts/one-per-page/commit/093509f))
<a name="3.1.1"></a>

@@ -2,0 +9,0 @@ ## 3.1.1 (2018-03-07)

2

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/hmcts/one-per-page#readme",
"version": "3.1.1",
"version": "3.1.2",
"main": "./src/main.js",

@@ -8,0 +8,0 @@ "repository": {

@@ -9,6 +9,8 @@ const { notDefined } = require('../util/checks');

const fieldsProp = Symbol('fields');
const filled = Symbol('filledFromTemp');
class FilledForm {
constructor(fieldValues = {}) {
constructor(fieldValues = {}, filledFromTemp = false) {
this[fieldsProp] = fieldValues;
this[filled] = filledFromTemp;

@@ -82,3 +84,3 @@ Object.entries(this.fields).forEach(([key, field]) => {

get isFilled() {
return Object.values(this.fields)
return this[filled] || Object.values(this.fields)
.some(field => field.isFilled);

@@ -85,0 +87,0 @@ }

@@ -37,3 +37,3 @@ const { notDefined } = require('../util/checks');

);
return filledForm(fieldValues);
return filledForm(fieldValues, tempValues.isSome());
}

@@ -40,0 +40,0 @@ }

@@ -187,3 +187,26 @@ const { expect, sinon } = require('../util/chai');

});
describe('#isFilled', () => {
it('returns true if any field has values', () => {
const filled = text.parse('foo', { foo: 'A Value' });
const f = new FilledForm({ foo: filled });
expect(f.isFilled).to.be.true;
});
it('returns true if filled from temp', () => {
const notFilled = text.parse('foo', {});
const f = new FilledForm({ foo: notFilled }, true);
expect(f.isFilled).to.be.true;
});
it('returns false otherwise', () => {
const notFilled = text.parse('foo', {});
const f = new FilledForm({ foo: notFilled });
expect(f.isFilled).to.be.false;
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc