-
Notifications
You must be signed in to change notification settings - Fork 279
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
May 6, 2020
1 parent
ba9140f
commit d41963a
Showing
49 changed files
with
7,729 additions
and
2,332 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,51 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
import validate from '../utils/validate'; | ||
import fixtures from './__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,147 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
import validate from '../utils/validate'; | ||
import fixtures from './__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,27 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
import Ajv from 'ajv'; | ||
import fixtures from './__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(); | ||
}); |
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,91 @@ | ||
import {describe, expect, it} from '@jest/globals' | ||
import validate from '../utils/validate'; | ||
import fixtures from './__test__/education.json'; | ||
|
||
test('eductaion - valid', () => { | ||
expect(validate(fixtures.educationValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education - invalid', () => { | ||
expect(validate(fixtures.educationInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].institution - valid', () => { | ||
expect(validate(fixtures.institutionValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].institution - invalid', () => { | ||
expect(validate(fixtures.institutionInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].area - valid', () => { | ||
expect(validate(fixtures.areaValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].area - invalid', () => { | ||
expect(validate(fixtures.areaInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].studyType - valid', () => { | ||
expect(validate(fixtures.studyTypeValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].studyType - invalid', () => { | ||
expect(validate(fixtures.studyTypeInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].startDate - valid [YYYY-MM-DD]', () => { | ||
expect(validate(fixtures.startDateValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].startDate - valid [YYYY-MM]', () => { | ||
expect(validate(fixtures.startDateValid2, )).toBeTruthy(); | ||
}); | ||
|
||
test('education[].startDate - valid [YYYY]', () => { | ||
expect(validate(fixtures.startDateValid3)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].startDate - invalid', () => { | ||
expect(validate(fixtures.startDateInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].endDate - valid [YYYY-MM-DD]', () => { | ||
expect(validate(fixtures.endDateValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].endDate - valid [YYYY-MM]', () => { | ||
expect(validate(fixtures.endDateValid2)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].endDate - valid [YYYY]', () => { | ||
expect(validate(fixtures.endDateValid3)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].endDate - invalid', () => { | ||
expect(validate(fixtures.endDateInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].gpa - valid', () => { | ||
expect(validate(fixtures.gpaValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].gpa - invalid', () => { | ||
expect(validate(fixtures.gpaInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].courses - valid', () => { | ||
expect(validate(fixtures.coursesValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].courses - invalid', () => { | ||
expect(validate(fixtures.coursesInvalid)).toBeFalsy(); | ||
}); | ||
|
||
test('education[].courses[item] - valid', () => { | ||
expect(validate(fixtures.coursesItemValid)).toBeTruthy(); | ||
}); | ||
|
||
test('education[].courses[item] - invalid', () => { | ||
expect(validate(fixtures.coursesItemInvalid)).toBeFalsy(); | ||
}); |
Oops, something went wrong.