-
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.
Merge pull request #47 from scottnath/hotfix/val
remove old validation
- Loading branch information
Showing
4 changed files
with
28 additions
and
26 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
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,37 +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'); | ||
}); | ||
|
||
// Invalid input | ||
test('validate correct input', t => { | ||
const ip = input; | ||
ip.target.value = ''; | ||
|
||
t.is(validation(ip, settings), 'date cannot be left blank!', 'Return string if not valid'); | ||
// Valid input | ||
test('bad input', t => { | ||
t.is(validation(bad), 'bad must be a date!', 'Bad input returns true'); | ||
}); |