diff --git a/gh-badges/README.md b/gh-badges/README.md index 048b6e5c2531b..3cbb77362fc53 100644 --- a/gh-badges/README.md +++ b/gh-badges/README.md @@ -21,7 +21,7 @@ badge build passed :green .png > mybadge.png ### As a library ```js -const { BadgeFactory } = require('gh-badges') +const { BadgeFactory, ValidationError } = require('gh-badges') const bf = new BadgeFactory() @@ -31,7 +31,8 @@ const format = { template: 'flat', } -const svg = bf.create(format) +bf.create(format) // bf.create({})).to.throw( + ValidationError, + 'Field `text` is required' + ) + expect(() => bf.create({ text: ['build'] })).to.throw( + ValidationError, + 'Field `text` must be an array of 2 strings' + ) + expect(() => + bf.create({ text: ['build', 'passed', 'something else'] }) + ).to.throw(ValidationError, 'Field `text` must be an array of 2 strings') + expect(() => + bf.create({ text: ['build', 'passed'], labelColor: 7 }) + ).to.throw(ValidationError, 'Field `labelColor` must be of type string') + expect(() => + bf.create({ text: ['build', 'passed'], format: 'png' }) + ).to.throw(ValidationError, 'Field `format` must be one of (svg,json)') + expect(() => + bf.create({ text: ['build', 'passed'], template: 'something else' }) + ).to.throw( + ValidationError, + 'Field `template` must be one of (plastic,flat,flat-square,for-the-badge,popout,popout-square,social)' + ) }) })