Skip to content

Commit

Permalink
Prettier bracketSpacing
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Jan 20, 2018
1 parent fdcc639 commit 2b75e53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"bracketSpacing": false,
"printWidth": 80,
"semi": false,
"singleQuote": true
Expand Down
2 changes: 1 addition & 1 deletion src/partial.lenses.validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const pargs = (name, fn) =>
export const cases = pargs('cases', L.ifElse)
export const unless = pargs('unless', (c, a, r) => L.ifElse(c, r, reject(a)))

export { choose } from 'partial.lenses'
export {choose} from 'partial.lenses'

export const optional = rules => L.toFunction([L.optional, rules])

Expand Down
29 changes: 13 additions & 16 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,32 @@ describe('ad hoc', () => {
{
id: 1,
rules: [3, 2, 1],
cases: [{}, { a: 0 }, { b: 0 }]
cases: [{}, {a: 0}, {b: 0}]
},
{ array: [] }
{array: []}
]
)
)
})

describe('V.optional', () => {
testEq([null, null, { x: 'not one' }], () =>
testEq([null, null, {x: 'not one'}], () =>
V.validate(
V.arrayIx(
V.object([], {
x: V.optional(V.unless([R.equals(1), 'not one']))
})
),
[{ y: 1 }, { x: 1 }, { x: 2 }]
[{y: 1}, {x: 1}, {x: 2}]
)
)
})

describe('V.object', () => {
R.forEach(
v =>
testEq({ required: 'error' }, () =>
V.validate(
V.object([], { required: V.unless([R.identity, 'error']) }),
v
)
testEq({required: 'error'}, () =>
V.validate(V.object([], {required: V.unless([R.identity, 'error'])}), v)
),
[{}, null, 42, 'anything', []]
)
Expand All @@ -114,15 +111,15 @@ describe('V.arrayId', () => {
describe('V.objectWith', () => {
testEq(undefined, () =>
V.validate(
V.object([], { foo: V.objectWith(V.reject('unexpected'), [], {}) }),
{ foo: {} }
V.object([], {foo: V.objectWith(V.reject('unexpected'), [], {})}),
{foo: {}}
)
)

testEq(
[
{ optional: 'not one', required: 'not one', id: 2, extra: 'unexpected' },
{ id: 3, extra: 'unexpected' }
{optional: 'not one', required: 'not one', id: 2, extra: 'unexpected'},
{id: 3, extra: 'unexpected'}
],
() =>
V.validate(
Expand All @@ -133,9 +130,9 @@ describe('V.objectWith', () => {
})
),
[
{ id: 1, optional: 1, required: 1 },
{ id: 2, optional: 2, required: 2, extra: 2 },
{ id: 3, required: 1, extra: 2 }
{id: 1, optional: 1, required: 1},
{id: 2, optional: 2, required: 2, extra: 2},
{id: 3, required: 1, extra: 2}
]
)
)
Expand Down

0 comments on commit 2b75e53

Please sign in to comment.