-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generate): basic zine structure (#5)
* Template stuff * Copied template * init * Copy * Remove validate * Provide rankRules * Actual function * Remove cache dependency * Use versions * Basic controller * Basic rank-score test * Add tests * Test empty items * Update package json * Args for testing * Ignore test results * Fixed formatting * Test no rankRules * Common libraries * Error handler * common files * Include assert * Fixed XO * Fixed etst-results name * Moved validation error to common * Validate function * Use common * Fixed xo * Moved validate.js to common * Tested some basic things * Test boolean * Test all Booleans * Added integers * Decimal * Boolean type * Validated arrays * Version Object * TEst version * Replaced with common * Make it incomplete * Fixed XO * Validate int-test Dockerfile * test empty rank * Test single object * Place identifier in output * Support providing an identifier field * Test numbers prefer lower * Test for version * Finish testing * sonar scan * Renamed to match service * Fixed imports * Dummy code for now * Renamed file * Basic routing * make it simpler * Fixed path * Fixed correct order of error handling * Renamed to apiDocs * Renamed to match file * Renamed
- Loading branch information
1 parent
9e06b4d
commit 08b51c0
Showing
23 changed files
with
969 additions
and
137 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,249 @@ | ||
import chai from 'chai'; | ||
import {validate, ValidationError} from '../src/index.js'; | ||
|
||
const {expect} = chai; | ||
|
||
const everything = {s: 'a', b: true, i: 1, d: 1.1, a: [1, 2, 3], o: {name: 'Object'}}; | ||
|
||
describe('Basic Validation', function () { | ||
it('Empty rules', function () { | ||
validate(everything, {}); | ||
}); | ||
|
||
it('More attributes than expected', function () { | ||
validate(everything, { | ||
z: {presence: false, type: 'string'}, | ||
}); | ||
}); | ||
|
||
it('Required attributes', function () { | ||
validate(everything, { | ||
s: {presence: true}, | ||
}); | ||
}); | ||
|
||
describe('Sting Validations', function () { | ||
it('String', function () { | ||
expect(function () { | ||
validate(everything, { | ||
s: {presence: false, type: 'string'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Bool', function () { | ||
expect(function () { | ||
validate(everything, { | ||
b: {presence: false, type: 'string'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Integer', function () { | ||
expect(function () { | ||
validate(everything, { | ||
i: {presence: false, type: 'string'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Decimal', function () { | ||
expect(function () { | ||
validate(everything, { | ||
d: {presence: false, type: 'string'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Array', function () { | ||
expect(function () { | ||
validate(everything, { | ||
a: {presence: false, type: 'string'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Object', function () { | ||
expect(function () { | ||
validate(everything, { | ||
o: {presence: false, type: 'string'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
}); | ||
|
||
describe('Boolean Validations', function () { | ||
it('String', function () { | ||
expect(function () { | ||
validate(everything, { | ||
s: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Bool', function () { | ||
expect(function () { | ||
validate(everything, { | ||
b: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Integer', function () { | ||
expect(function () { | ||
validate(everything, { | ||
i: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Decimal', function () { | ||
expect(function () { | ||
validate(everything, { | ||
d: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Array', function () { | ||
expect(function () { | ||
validate(everything, { | ||
a: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Object', function () { | ||
expect(function () { | ||
validate(everything, { | ||
o: {presence: false, type: 'boolean'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
}); | ||
|
||
describe('Integer Validations', function () { | ||
it('String', function () { | ||
expect(function () { | ||
validate(everything, { | ||
s: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Bool', function () { | ||
expect(function () { | ||
validate(everything, { | ||
b: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Integer', function () { | ||
expect(function () { | ||
validate(everything, { | ||
i: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Decimal', function () { | ||
expect(function () { | ||
validate(everything, { | ||
d: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Array', function () { | ||
expect(function () { | ||
validate(everything, { | ||
a: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Object', function () { | ||
expect(function () { | ||
validate(everything, { | ||
o: {presence: false, type: 'integer'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
}); | ||
|
||
describe('Decimal Validations', function () { | ||
it('String', function () { | ||
expect(function () { | ||
validate(everything, { | ||
s: {presence: false, type: 'number'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Bool', function () { | ||
expect(function () { | ||
validate(everything, { | ||
b: {presence: false, type: 'number'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Integer', function () { | ||
expect(function () { | ||
validate(everything, { | ||
i: {presence: false, type: 'number'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Decimal', function () { | ||
expect(function () { | ||
validate(everything, { | ||
d: {presence: false, type: 'number'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Array', function () { | ||
expect(function () { | ||
validate(everything, { | ||
a: {presence: false, type: 'number'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Object', function () { | ||
expect(function () { | ||
validate(everything, { | ||
o: {presence: false, type: 'number'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
}); | ||
|
||
describe('Arrray Validations', function () { | ||
it('String', function () { | ||
expect(function () { | ||
validate(everything, { | ||
s: {presence: false, type: 'array'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Bool', function () { | ||
expect(function () { | ||
validate(everything, { | ||
b: {presence: false, type: 'array'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Integer', function () { | ||
expect(function () { | ||
validate(everything, { | ||
i: {presence: false, type: 'array'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Decimal', function () { | ||
expect(function () { | ||
validate(everything, { | ||
d: {presence: false, type: 'array'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
it('Array', function () { | ||
expect(function () { | ||
validate(everything, { | ||
a: {presence: false, type: 'array'}, | ||
}); | ||
}).to.not.throw(ValidationError); | ||
}); | ||
it('Object', function () { | ||
expect(function () { | ||
validate(everything, { | ||
o: {presence: false, type: 'array'}, | ||
}); | ||
}).to.throw(ValidationError); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.