-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
3 changed files
with
32 additions
and
15 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
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 |
---|---|---|
@@ -1,29 +1,38 @@ | ||
import test from 'ava'; | ||
import validation from '../lib/validation'; | ||
|
||
const input = { | ||
const empty = { | ||
target: { | ||
name: 'date', | ||
value: 'foo bar baz', | ||
}, | ||
all: { | ||
date: 'foo bar baz', | ||
name: 'empty', | ||
value: '', | ||
}, | ||
}; | ||
|
||
const settings = { | ||
const input = { | ||
target: { | ||
empty: false, | ||
name: 'good', | ||
value: '1972-08-21', | ||
}, | ||
all: { | ||
date: { | ||
empty: false, | ||
}, | ||
}; | ||
|
||
const bad = { | ||
target: { | ||
name: 'bad', | ||
value: '1972-08-foo', | ||
}, | ||
}; | ||
|
||
// Empty input | ||
test('empty input', t => { | ||
t.true(validation(empty), 'Empty input returns true'); | ||
}); | ||
|
||
// Valid input | ||
test('valid input', t => { | ||
t.true(validation(input, settings), 'Valid input returns true'); | ||
t.true(validation(input), 'Valid input returns true'); | ||
}); | ||
|
||
// Valid input | ||
test('bad input', t => { | ||
t.is(validation(bad), 'bad must be a date!', 'Bad input returns true'); | ||
}); |