-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7614bad
commit a3a72c3
Showing
7 changed files
with
353 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Controller = require('hof').controller; | ||
|
||
const DummyController = class DummyControllerBase extends Controller { | ||
configure(req, res, next) { | ||
super.configure(req, res, next); | ||
} | ||
}; | ||
describe('apps/collection/fields/application-type', () => { | ||
let controller; | ||
let req; | ||
let res; | ||
|
||
beforeEach(() => { | ||
req = reqres.req(); | ||
res = reqres.res(); | ||
|
||
req.form.options = {}; | ||
|
||
controller = new DummyController({ template: 'index', route: '/index' }); | ||
}); | ||
|
||
describe('validation', () => { | ||
let sandbox; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
req.form.options.fields = { | ||
'application-type': { | ||
validate: ['required'] | ||
}, | ||
'application-type-other': { | ||
validate: ['required'] | ||
} | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('adds a `required` validator if the application type is not selected', () => { | ||
req.sessionModel.set('application-type'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type'].validate).to.deep.eql(['required' ]); | ||
}); | ||
}); | ||
|
||
it('adds a`required` validator to the `other` input box', () => { | ||
req.sessionModel.set('application-type', 'other'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type-other'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type-other'].validate).to.deep.eql([ 'required']); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
test/_unit/apps/correct-mistakes/validation/validation.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Controller = require('hof').controller; | ||
|
||
const DummyController = class DummyControllerBase extends Controller { | ||
configure(req, res, next) { | ||
super.configure(req, res, next); | ||
} | ||
}; | ||
describe('apps/correct-mistakes/fields/application-type', () => { | ||
let controller; | ||
let req; | ||
let res; | ||
|
||
beforeEach(() => { | ||
req = reqres.req(); | ||
res = reqres.res(); | ||
|
||
req.form.options = {}; | ||
|
||
controller = new DummyController({ template: 'index', route: '/index' }); | ||
}); | ||
|
||
describe('validation', () => { | ||
let sandbox; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
req.form.options.fields = { | ||
'application-type': { | ||
validate: ['required'] | ||
}, | ||
'application-type-other': { | ||
validate: ['required'] | ||
} | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('adds a `required` validator if the application type is not selected', () => { | ||
req.sessionModel.set('application-type'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type'].validate).to.deep.eql(['required' ]); | ||
}); | ||
}); | ||
|
||
it('adds a`required` validator to the `other` input box', () => { | ||
req.sessionModel.set('application-type', 'other'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type-other'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type-other'].validate).to.deep.eql([ 'required']); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Controller = require('hof').controller; | ||
|
||
const DummyController = class DummyControllerBase extends Controller { | ||
configure(req, res, next) { | ||
super.configure(req, res, next); | ||
} | ||
}; | ||
describe('apps/lost-stolen/fields/application-type', () => { | ||
let controller; | ||
let req; | ||
let res; | ||
|
||
beforeEach(() => { | ||
req = reqres.req(); | ||
res = reqres.res(); | ||
|
||
req.form.options = {}; | ||
|
||
controller = new DummyController({ template: 'index', route: '/index' }); | ||
}); | ||
|
||
describe('validation', () => { | ||
let sandbox; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
req.form.options.fields = { | ||
'application-type': { | ||
validate: ['required'] | ||
}, | ||
'application-type-other': { | ||
validate: ['required'] | ||
} | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('adds a `required` validator if the application type is not selected', () => { | ||
req.sessionModel.set('application-type'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type'].validate).to.deep.eql(['required' ]); | ||
}); | ||
}); | ||
|
||
it('adds a`required` validator to the `other` input box', () => { | ||
req.sessionModel.set('application-type', 'other'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type-other'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type-other'].validate).to.deep.eql([ 'required']); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Controller = require('hof').controller; | ||
|
||
const DummyController = class DummyControllerBase extends Controller { | ||
configure(req, res, next) { | ||
super.configure(req, res, next); | ||
} | ||
}; | ||
describe('apps/not-arrived/fields/application-type', () => { | ||
let controller; | ||
let req; | ||
let res; | ||
|
||
beforeEach(() => { | ||
req = reqres.req(); | ||
res = reqres.res(); | ||
|
||
req.form.options = {}; | ||
|
||
controller = new DummyController({ template: 'index', route: '/index' }); | ||
}); | ||
|
||
describe('validation', () => { | ||
let sandbox; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
req.form.options.fields = { | ||
'application-type': { | ||
validate: ['required'] | ||
}, | ||
'application-type-other': { | ||
validate: ['required'] | ||
} | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('adds a `required` validator if the application type is not selected', () => { | ||
req.sessionModel.set('application-type'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type'].validate).to.deep.eql(['required' ]); | ||
}); | ||
}); | ||
|
||
it('adds a`required` validator to the `other` input box', () => { | ||
req.sessionModel.set('application-type', 'other'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type-other'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type-other'].validate).to.deep.eql([ 'required']); | ||
}); | ||
}); | ||
}); | ||
}); |
59 changes: 59 additions & 0 deletions
59
test/_unit/apps/someone-else/validation/validation.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const Controller = require('hof').controller; | ||
|
||
const DummyController = class DummyControllerBase extends Controller { | ||
configure(req, res, next) { | ||
super.configure(req, res, next); | ||
} | ||
}; | ||
describe('apps/someone-else/fields/application-type', () => { | ||
let controller; | ||
let req; | ||
let res; | ||
|
||
beforeEach(() => { | ||
req = reqres.req(); | ||
res = reqres.res(); | ||
|
||
req.form.options = {}; | ||
|
||
controller = new DummyController({ template: 'index', route: '/index' }); | ||
}); | ||
|
||
describe('validation', () => { | ||
let sandbox; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.createSandbox(); | ||
req.form.options.fields = { | ||
'application-type': { | ||
validate: ['required'] | ||
}, | ||
'application-type-other': { | ||
validate: ['required'] | ||
} | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('adds a `required` validator if the application type is not selected', () => { | ||
req.sessionModel.set('application-type'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type'].validate).to.deep.eql(['required' ]); | ||
}); | ||
}); | ||
|
||
it('adds a`required` validator to the `other` input box', () => { | ||
req.sessionModel.set('application-type', 'other'); | ||
controller.configure(req, res, () => { | ||
req.form.options.fields['application-type-other'].should.have.property('validate'); | ||
expect(req.form.options.fields['application-type-other'].validate).to.deep.eql([ 'required']); | ||
}); | ||
}); | ||
}); | ||
}); |