Avoid certain cases for data consistency (#7222)

This commit is contained in:
Álvaro Mondéjar 2022-03-14 21:04:50 +01:00 committed by GitHub
parent c05890dc5f
commit dd4ddc7fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 19 deletions

View File

@ -55,22 +55,6 @@
"license": { "license": {
"description": "The license for the icon", "description": "The license for the icon",
"oneOf": [ "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", "type": "object",
"required": ["type"], "required": ["type"],
@ -166,6 +150,22 @@
} }
}, },
"additionalProperties": false "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]+$" "pattern": "^https?://[^\\s]+$"
} }
}, },
"type": "object", "type": "object",
"properties": { "properties": {
"icons": { "icons": {
@ -243,5 +242,7 @@
"type": "array", "type": "array",
"items": { "$ref": "#/definitions/brand" } "items": { "$ref": "#/definitions/brand" }
} }
} },
"additionalProperties": false,
"required": ["icons"]
} }

View File

@ -1,5 +1,5 @@
import simpleIcons from '../index.js'; 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 { test } from 'mocha';
import { strict as assert } from 'node:assert'; 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.hex, icon.hex);
assert.equal(found.source, icon.source); 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`, () => { test(`Iterating over simpleIcons only exposes icons`, () => {