11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { MIMEType } = require('util'); 61cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cifunction test(mimes) { 91cb0ef41Sopenharmony_ci for (const entry of mimes) { 101cb0ef41Sopenharmony_ci if (typeof entry === 'string') continue; 111cb0ef41Sopenharmony_ci const { input, output } = entry; 121cb0ef41Sopenharmony_ci if (output === null) { 131cb0ef41Sopenharmony_ci assert.throws(() => new MIMEType(input), /ERR_INVALID_MIME_SYNTAX/i); 141cb0ef41Sopenharmony_ci } else { 151cb0ef41Sopenharmony_ci const str = `${new MIMEType(input)}`; 161cb0ef41Sopenharmony_ci assert.strictEqual(str, output); 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci } 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci// These come from https://github.com/web-platform-tests/wpt/tree/master/mimesniff/mime-types/resources 221cb0ef41Sopenharmony_citest(require(fixtures.path('./mime-whatwg.js'))); 231cb0ef41Sopenharmony_citest(require(fixtures.path('./mime-whatwg-generated.js'))); 24