File tree Expand file tree Collapse file tree 3 files changed +31
-7
lines changed
Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ const convertToFormErrors = (err) => {
66 return errors ;
77} ;
88
9- // @todo #3:30min Add tests
109export const createFormSchemaValidator = schema => ( fields ) => {
1110 try {
1211 schema . omit ( '_id' ) . validator ( ) ( fields ) ;
Original file line number Diff line number Diff line change 1+ import SimpleSchema from 'simpl-schema' ;
2+ import { createFormSchemaValidator } from './form' ;
3+ import chai from 'chai' ;
4+
5+ chai . should ( ) ;
6+
7+ describe ( 'form validation' , ( ) => {
8+ const schema = new SimpleSchema ( {
9+ name : { type : String }
10+ } ) ;
11+ const validator = createFormSchemaValidator ( schema ) ;
12+
13+ it ( 'should use schema validator' , ( ) => {
14+ const result = validator ( { } ) ;
15+ const expectedErrors = { name : 'Name is required' } ;
16+ result . should . deep . equal ( expectedErrors ) ;
17+ } ) ;
18+
19+ it ( 'should return an empty object when no errors' , ( ) => {
20+ validator ( { name : 'asd' } ) . should . deep . equal ( { } ) ;
21+ } ) ;
22+
23+ it ( 'should omit _id field' , ( ) => {
24+ const schemaWithId = new SimpleSchema ( {
25+ name : { type : String } ,
26+ _id : { type : String } ,
27+ } ) ;
28+
29+ createFormSchemaValidator ( schemaWithId ) ( { name : 'asd' } ) . should . deep . equal ( { } ) ;
30+ } ) ;
31+ } ) ;
Original file line number Diff line number Diff line change 11const SCREENSHOT_PATH = process . env . CIRCLE_ARTIFACTS || 'nightwatch-output/screenshots' ;
22
3- // TODO add these to package.json
4- // ,
5- // "nightmare": "^2.10.0",
6- // "nightwatch": "^0.9.19",
7- // "selenium-server-standalone-jar": "3.8.1"
8-
93module . exports = {
104 src_folders : [
115 'tests/fixtures'
You can’t perform that action at this time.
0 commit comments