import { color } from '@csstools/css-color-parser';
import assert from 'node:assert';
import { parse } from '../util/parse.mjs';
import { serialize_sRGB_data } from '../util/serialize.mjs';

const tests = [
	['', 'Should not parse invalid keyword'],
	[' /* hey */\n', 'Should not parse invalid keyword'],
	['4', 'Should not parse invalid keyword'],
	['top', 'Should not parse invalid keyword'],
	['current-Color', 'Should not parse invalid keyword'],

	['ransparent', 'Partial keywords shouldn\'t parse'],
	['aiceblue', 'Partial keywords shouldn\'t parse'],
	['aniquewhite', 'Partial keywords shouldn\'t parse'],
	['aqu', 'Partial keywords shouldn\'t parse'],
	['aquaarine', 'Partial keywords shouldn\'t parse'],
	['zure', 'Partial keywords shouldn\'t parse'],
	['bige', 'Partial keywords shouldn\'t parse'],
	['bsque', 'Partial keywords shouldn\'t parse'],
	['blak', 'Partial keywords shouldn\'t parse'],
	['blacK', 'Unicode modification shouldn\'t parse'],
	['blanchedamond', 'Partial keywords shouldn\'t parse'],
	['ble', 'Partial keywords shouldn\'t parse'],
	['bueviolet', 'Partial keywords shouldn\'t parse'],
	['brwn', 'Partial keywords shouldn\'t parse'],
	['burlwood', 'Partial keywords shouldn\'t parse'],
	['cadetlue', 'Partial keywords shouldn\'t parse'],
	['charteuse', 'Partial keywords shouldn\'t parse'],
	['chocolae', 'Partial keywords shouldn\'t parse'],
	['coal', 'Partial keywords shouldn\'t parse'],
	['cornlowerblue', 'Partial keywords shouldn\'t parse'],
	['corsilk', 'Partial keywords shouldn\'t parse'],
	['cornsilK', 'Unicode modification shouldn\'t parse'],
	['crimso', 'Partial keywords shouldn\'t parse'],
	['can', 'Partial keywords shouldn\'t parse'],
	['darkble', 'Partial keywords shouldn\'t parse'],
	['darKblue', 'Unicode modification shouldn\'t parse'],
	['darkcya', 'Partial keywords shouldn\'t parse'],
	['darKcyan', 'Unicode modification shouldn\'t parse'],
	['darkgoldenrd', 'Partial keywords shouldn\'t parse'],
	['darKgoldenrod', 'Unicode modification shouldn\'t parse'],
	['drkgray', 'Partial keywords shouldn\'t parse'],
	['darKgray', 'Unicode modification shouldn\'t parse'],
	['darkgree', 'Partial keywords shouldn\'t parse'],
	['darKgreen', 'Unicode modification shouldn\'t parse'],
	['dargrey', 'Partial keywords shouldn\'t parse'],
	['darKgrey', 'Unicode modification shouldn\'t parse'],
	['drkkhaki', 'Partial keywords shouldn\'t parse'],
	['darKkhaki', 'Unicode modification shouldn\'t parse'],
	['darkmagnta', 'Partial keywords shouldn\'t parse'],
	['darKmagenta', 'Unicode modification shouldn\'t parse'],
	['dakolivegreen', 'Partial keywords shouldn\'t parse'],
	['darKolivegreen', 'Unicode modification shouldn\'t parse'],
	['drkorange', 'Partial keywords shouldn\'t parse'],
	['darKorange', 'Unicode modification shouldn\'t parse'],
	['dakorchid', 'Partial keywords shouldn\'t parse'],
	['darKorchid', 'Unicode modification shouldn\'t parse'],
	['darkrd', 'Partial keywords shouldn\'t parse'],
	['darKred', 'Unicode modification shouldn\'t parse'],
	['darkalmon', 'Partial keywords shouldn\'t parse'],
	['darKsalmon', 'Unicode modification shouldn\'t parse'],
	['darkseagree', 'Partial keywords shouldn\'t parse'],
	['darKseagreen', 'Unicode modification shouldn\'t parse'],
	['darkslatebue', 'Partial keywords shouldn\'t parse'],
	['darKslateblue', 'Unicode modification shouldn\'t parse'],
	['darkslategry', 'Partial keywords shouldn\'t parse'],
	['darKslategray', 'Unicode modification shouldn\'t parse'],
	['darkslategre', 'Partial keywords shouldn\'t parse'],
	['darKslategrey', 'Unicode modification shouldn\'t parse'],
	['arkturquoise', 'Partial keywords shouldn\'t parse'],
	['darKturquoise', 'Unicode modification shouldn\'t parse'],
	['arkviolet', 'Partial keywords shouldn\'t parse'],
	['darKviolet', 'Unicode modification shouldn\'t parse'],
	['deppink', 'Partial keywords shouldn\'t parse'],
	['deeppinK', 'Unicode modification shouldn\'t parse'],
	['deepskyble', 'Partial keywords shouldn\'t parse'],
	['deepsKyblue', 'Unicode modification shouldn\'t parse'],
	['dmgray', 'Partial keywords shouldn\'t parse'],
	['digrey', 'Partial keywords shouldn\'t parse'],
	['dodgeblue', 'Partial keywords shouldn\'t parse'],
	['frebrick', 'Partial keywords shouldn\'t parse'],
	['firebricK', 'Unicode modification shouldn\'t parse'],
	['floalwhite', 'Partial keywords shouldn\'t parse'],
	['foretgreen', 'Partial keywords shouldn\'t parse'],
	['uchsia', 'Partial keywords shouldn\'t parse'],
	['gainsoro', 'Partial keywords shouldn\'t parse'],
	['gostwhite', 'Partial keywords shouldn\'t parse'],
	['old', 'Partial keywords shouldn\'t parse'],
	['goldenro', 'Partial keywords shouldn\'t parse'],
	['gry', 'Partial keywords shouldn\'t parse'],
	['reen', 'Partial keywords shouldn\'t parse'],
	['geenyellow', 'Partial keywords shouldn\'t parse'],
	['gey', 'Partial keywords shouldn\'t parse'],
	['hoeydew', 'Partial keywords shouldn\'t parse'],
	['hotink', 'Partial keywords shouldn\'t parse'],
	['hotpinK', 'Unicode modification shouldn\'t parse'],
	['indianed', 'Partial keywords shouldn\'t parse'],
	['idigo', 'Partial keywords shouldn\'t parse'],
	['ivry', 'Partial keywords shouldn\'t parse'],
	['khai', 'Partial keywords shouldn\'t parse'],
	['Khaki', 'Unicode modification shouldn\'t parse'],
	['avender', 'Partial keywords shouldn\'t parse'],
	['avenderblush', 'Partial keywords shouldn\'t parse'],
	['lawgreen', 'Partial keywords shouldn\'t parse'],
	['lemonchffon', 'Partial keywords shouldn\'t parse'],
	['lightlue', 'Partial keywords shouldn\'t parse'],
	['lightcora', 'Partial keywords shouldn\'t parse'],
	['lightcyn', 'Partial keywords shouldn\'t parse'],
	['lightgoldenodyellow', 'Partial keywords shouldn\'t parse'],
	['ightgray', 'Partial keywords shouldn\'t parse'],
	['ligtgreen', 'Partial keywords shouldn\'t parse'],
	['lihtgrey', 'Partial keywords shouldn\'t parse'],
	['ligtpink', 'Partial keywords shouldn\'t parse'],
	['lightpinK', 'Unicode modification shouldn\'t parse'],
	['lightsalmo', 'Partial keywords shouldn\'t parse'],
	['lightseagree', 'Partial keywords shouldn\'t parse'],
	['lightsyblue', 'Partial keywords shouldn\'t parse'],
	['lightsKyblue', 'Unicode modification shouldn\'t parse'],
	['lightslatgray', 'Partial keywords shouldn\'t parse'],
	['lightslaterey', 'Partial keywords shouldn\'t parse'],
	['lightsteelbue', 'Partial keywords shouldn\'t parse'],
	['lightellow', 'Partial keywords shouldn\'t parse'],
	['lim', 'Partial keywords shouldn\'t parse'],
	['limgreen', 'Partial keywords shouldn\'t parse'],
	['inen', 'Partial keywords shouldn\'t parse'],
	['maenta', 'Partial keywords shouldn\'t parse'],
	['maron', 'Partial keywords shouldn\'t parse'],
	['mediumaqamarine', 'Partial keywords shouldn\'t parse'],
	['mediumblu', 'Partial keywords shouldn\'t parse'],
	['mediumrchid', 'Partial keywords shouldn\'t parse'],
	['mediumprple', 'Partial keywords shouldn\'t parse'],
	['mediumsegreen', 'Partial keywords shouldn\'t parse'],
	['medumslateblue', 'Partial keywords shouldn\'t parse'],
	['mediumsprnggreen', 'Partial keywords shouldn\'t parse'],
	['mediuturquoise', 'Partial keywords shouldn\'t parse'],
	['mediumioletred', 'Partial keywords shouldn\'t parse'],
	['mdnightblue', 'Partial keywords shouldn\'t parse'],
	['mintcrea', 'Partial keywords shouldn\'t parse'],
	['istyrose', 'Partial keywords shouldn\'t parse'],
	['moccsin', 'Partial keywords shouldn\'t parse'],
	['naajowhite', 'Partial keywords shouldn\'t parse'],
	['nay', 'Partial keywords shouldn\'t parse'],
	['oldlae', 'Partial keywords shouldn\'t parse'],
	['oliv', 'Partial keywords shouldn\'t parse'],
	['olivedab', 'Partial keywords shouldn\'t parse'],
	['orane', 'Partial keywords shouldn\'t parse'],
	['orangere', 'Partial keywords shouldn\'t parse'],
	['rchid', 'Partial keywords shouldn\'t parse'],
	['palegldenrod', 'Partial keywords shouldn\'t parse'],
	['paegreen', 'Partial keywords shouldn\'t parse'],
	['paleturuoise', 'Partial keywords shouldn\'t parse'],
	['palevioltred', 'Partial keywords shouldn\'t parse'],
	['papyawhip', 'Partial keywords shouldn\'t parse'],
	['peachpff', 'Partial keywords shouldn\'t parse'],
	['per', 'Partial keywords shouldn\'t parse'],
	['ink', 'Partial keywords shouldn\'t parse'],
	['pinK', 'Unicode modification shouldn\'t parse'],
	['pum', 'Partial keywords shouldn\'t parse'],
	['powderble', 'Partial keywords shouldn\'t parse'],
	['purpl', 'Partial keywords shouldn\'t parse'],
	['ed', 'Partial keywords shouldn\'t parse'],
	['rosyrown', 'Partial keywords shouldn\'t parse'],
	['royallue', 'Partial keywords shouldn\'t parse'],
	['sadlebrown', 'Partial keywords shouldn\'t parse'],
	['salmn', 'Partial keywords shouldn\'t parse'],
	['sandyrown', 'Partial keywords shouldn\'t parse'],
	['seagren', 'Partial keywords shouldn\'t parse'],
	['seashel', 'Partial keywords shouldn\'t parse'],
	['sinna', 'Partial keywords shouldn\'t parse'],
	['siler', 'Partial keywords shouldn\'t parse'],
	['skybue', 'Partial keywords shouldn\'t parse'],
	['sKyblue', 'Unicode modification shouldn\'t parse'],
	['slatelue', 'Partial keywords shouldn\'t parse'],
	['slategay', 'Partial keywords shouldn\'t parse'],
	['slategry', 'Partial keywords shouldn\'t parse'],
	['snw', 'Partial keywords shouldn\'t parse'],
	['sprnggreen', 'Partial keywords shouldn\'t parse'],
	['seelblue', 'Partial keywords shouldn\'t parse'],
	['ta', 'Partial keywords shouldn\'t parse'],
	['tel', 'Partial keywords shouldn\'t parse'],
	['thistl', 'Partial keywords shouldn\'t parse'],
	['toato', 'Partial keywords shouldn\'t parse'],
	['turquose', 'Partial keywords shouldn\'t parse'],
	['violt', 'Partial keywords shouldn\'t parse'],
	['whet', 'Partial keywords shouldn\'t parse'],
	['whit', 'Partial keywords shouldn\'t parse'],
	['whitemoke', 'Partial keywords shouldn\'t parse'],
	['whitesmoKe', 'Unicode modification shouldn\'t parse'],
	['yelow', 'Partial keywords shouldn\'t parse'],
	['yellwgreen', 'Partial keywords shouldn\'t parse'],
];

for (const test of tests) {
	assert.deepStrictEqual(
		serialize_sRGB_data(color(parse(test[0]))),
		'',
		`"${test[0]}" : ${test[1]}`,
	);
}
