-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no longer exporting validator. using jest for tests
- Loading branch information
antialias
committed
Apr 23, 2020
1 parent
791c85e
commit 2c9ec79
Showing
45 changed files
with
814 additions
and
1,550 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,7 +1,7 @@ | ||
|
||
{ | ||
"valid": { | ||
"$schema": "foo-bar-baz" | ||
"$schema": "http://example.com/" | ||
}, | ||
"invalid": { | ||
"$schema": {} | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
import validate from '../utils/validate'; | ||
const fixtures = require('./__test__/awards.json'); | ||
|
||
test('awards - valid', () => { | ||
expect(validate(fixtures.awardsValid)).toBeTruthy(); | ||
}); | ||
|
||
test('awards - invalid', () => { | ||
expect(validate(fixtures.awardsInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('awards[].title - valid', () => { | ||
expect(validate(fixtures.titleValid)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].title - invalid', () => { | ||
expect(validate(fixtures.titleInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('awards[].date - valid [YYYY-MM-DD]', () => { | ||
expect(validate(fixtures.dateValid)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].date - valid [YYYY-MM]', () => { | ||
expect(validate(fixtures.dateValid2)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].date - valid [YYYY]', () => { | ||
expect(validate(fixtures.dateValid3)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].date - invalid', () => { | ||
expect(validate(fixtures.dateInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('awards[].awarder - valid', () => { | ||
expect(validate(fixtures.awarderValid)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].awarder - invalid', () => { | ||
expect(validate(fixtures.awarderInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('awards[].summary - valid', () => { | ||
expect(validate(fixtures.summaryValid)).toBeTruthy(); | ||
}); | ||
|
||
test('awards[].summary - invalid', () => { | ||
expect(validate(fixtures.summaryInvalid)).toBeFalsy(); | ||
}); |
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,146 @@ | ||
import validate from '../utils/validate'; | ||
const fixtures = require('./__test__/basics.json'); | ||
|
||
test('basics - valid', () => { | ||
expect(validate(fixtures.basicsValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics - invalid', () => { | ||
expect(validate(fixtures.basicsInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.name - valid', () => { | ||
expect(validate(fixtures.nameValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.name - invalid', () => { | ||
expect(validate(fixtures.nameInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.label - valid', () => { | ||
expect(validate(fixtures.labelValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.label - invalid', () => { | ||
expect(validate(fixtures.labelInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.image - valid', () => { | ||
expect(validate(fixtures.imageValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.image - invalid', () => { | ||
expect(validate(fixtures.imageInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.email - valid', () => { | ||
expect(validate(fixtures.emailValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.email - invalid', () => { | ||
expect(validate(fixtures.emailInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.phone - valid', () => { | ||
expect(validate(fixtures.phoneValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.phone - invalid', () => { | ||
expect(validate(fixtures.phoneInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.url - valid', () => { | ||
expect(validate(fixtures.urlValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.url - invalid', () => { | ||
expect(validate(fixtures.urlInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.summary - valid', () => { | ||
expect(validate(fixtures.summaryValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.summary - invalid', () => { | ||
expect(validate(fixtures.summaryInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location - valid', () => { | ||
expect(validate(fixtures.locationValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location - invalid', () => { | ||
expect(validate(fixtures.locationInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location.address - valid', () => { | ||
expect(validate(fixtures.locationAddressValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location.address - invalid', () => { | ||
expect(validate(fixtures.locationAddressInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location.postal - valid', () => { | ||
expect(validate(fixtures.locationPostalValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location.postal - invalid', () => { | ||
expect(validate(fixtures.locationPostalInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location.city - valid', () => { | ||
expect(validate(fixtures.locationCityValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location.city - invalid', () => { | ||
expect(validate(fixtures.locationCityInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location.country - valid', () => { | ||
expect(validate(fixtures.locationCountryValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location.country - invalid', () => { | ||
expect(validate(fixtures.locationCountryInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.location.region - valid', () => { | ||
expect(validate(fixtures.locationRegionValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.location.region - invalid', () => { | ||
expect(validate(fixtures.locationRegionInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.profiles - valid', () => { | ||
expect(validate(fixtures.profilesValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.profiles - invalid', () => { | ||
expect(validate(fixtures.profilesInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.profiles[].network - valid', () => { | ||
expect(validate(fixtures.profilesNetworkValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.profiles[].network - invalid', () => { | ||
expect(validate(fixtures.profilesNetworkInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.profiles[].username - valid', () => { | ||
expect(validate(fixtures.profilesUsernameValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.profiles[].username - invalid', () => { | ||
expect(validate(fixtures.profilesUsernameInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('basics.profiles[].url - valid', () => { | ||
expect(validate(fixtures.profilesUrlValid)).toBeTruthy(); | ||
}); | ||
|
||
test('basics.profiles[].url - invalid', () => { | ||
expect(validate(fixtures.profilesUrlInvalid)).toBeFalsy(); | ||
}); |
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,26 @@ | ||
const Ajv = require('ajv'); | ||
const fixtures = require('./__test__/dates.json'); | ||
|
||
const mockDateSchema = { | ||
"type": "string", | ||
"description": "Mock Date Format", | ||
"pattern": "^([1-2][0-9]{3}-[0-1][0-9]-[0-3][0-9]|[1-2][0-9]{3}-[0-1][0-9]|[1-2][0-9]{3})$" | ||
}; | ||
|
||
const validate = new Ajv().compile(mockDateSchema) | ||
|
||
test('dates - YYYY-MM-DD', () => { | ||
expect(validate(fixtures.yearMonthDay)).toBeTruthy(); | ||
}); | ||
|
||
test('dates - YYYY-MM', () => { | ||
expect(validate(fixtures.yearMonth)).toBeTruthy(); | ||
}); | ||
|
||
test('dates - YYYY', () => { | ||
expect(validate(fixtures.yearMonthDay)).toBeTruthy(); | ||
}); | ||
|
||
test('dates - invalid', () => { | ||
expect(validate(fixtures.invalid)).toBeFalsy(); | ||
}); |
Oops, something went wrong.