diff --git a/.jsonschema.json b/.jsonschema.json index e70bd2195..e6134f209 100644 --- a/.jsonschema.json +++ b/.jsonschema.json @@ -55,22 +55,6 @@ "license": { "description": "The license for the icon", "oneOf": [ - { - "type": "object", - "required": ["type", "url"], - "properties": { - "type": { - "description": "The license name or 'custom'", - "type": "string", - "enum": ["custom"] - }, - "url": { - "description": "The URL to the license text by the brand", - "$ref": "#/definitions/url" - } - }, - "additionalProperties": false - }, { "type": "object", "required": ["type"], @@ -166,6 +150,22 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": ["type", "url"], + "properties": { + "type": { + "description": "The license name or 'custom'", + "type": "string", + "enum": ["custom"] + }, + "url": { + "description": "The URL to the license text by the brand", + "$ref": "#/definitions/url" + } + }, + "additionalProperties": false } ] } @@ -235,7 +235,6 @@ "pattern": "^https?://[^\\s]+$" } }, - "type": "object", "properties": { "icons": { @@ -243,5 +242,7 @@ "type": "array", "items": { "$ref": "#/definitions/brand" } } - } + }, + "additionalProperties": false, + "required": ["icons"] } diff --git a/tests/index.test.js b/tests/index.test.js index c8cc475d8..15a5748fb 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,5 +1,5 @@ import simpleIcons from '../index.js'; -import { getIconSlug, getIconsData } from '../scripts/utils.js'; +import { getIconSlug, getIconsData, titleToSlug } from '../scripts/utils.js'; import { test } from 'mocha'; import { strict as assert } from 'node:assert'; @@ -16,6 +16,15 @@ import { strict as assert } from 'node:assert'; assert.equal(found.hex, icon.hex); assert.equal(found.source, icon.source); }); + + if (icon.slug) { + // if an icon data has a slug, it must be different to the + // slug inferred from the title, which prevents adding + // unnecessary slugs to icons data + test(`'${icon.title}' slug must be necessary`, () => { + assert.notEqual(titleToSlug(icon.title), icon.slug); + }); + } }); test(`Iterating over simpleIcons only exposes icons`, () => {