2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-12 18:01:19 +00:00

Fix tests for SVG framework

This commit is contained in:
Vjacheslav Trushkin 2022-02-22 10:49:45 +02:00
parent c633283369
commit 5c6fdd19a3
2 changed files with 16 additions and 15 deletions

View File

@ -1,8 +1,9 @@
const fs = require('fs');
const path = require('path');
const { dirname } = require('path');
const child_process = require('child_process');
const packagesDir = path.dirname(__dirname);
const testsDir = __dirname;
const librariesDir = dirname(dirname(testsDir)) + '/packages';
// List of commands to run
const commands = [];
@ -56,19 +57,19 @@ const fileExists = (file) => {
return true;
};
if (compile.dist && !fileExists(packagesDir + '/browser-tests/lib/node.js')) {
if (compile.dist && !fileExists(testsDir + '/lib/node.js')) {
compile.lib = true;
}
if (
compile.lib &&
(!fileExists(packagesDir + '/iconify/dist/iconify.js') ||
!fileExists(packagesDir + '/iconify/lib/iconify.js'))
(!fileExists(librariesDir + '/iconify/dist/iconify.js') ||
!fileExists(librariesDir + '/iconify/lib/iconify.js'))
) {
compile.iconify = true;
}
if (compile.iconify && !fileExists(packagesDir + '/core/lib/modules.js')) {
if (compile.iconify && !fileExists(librariesDir + '/core/lib/modules.js')) {
compile.core = true;
}
@ -77,7 +78,7 @@ if (compile.core) {
commands.push({
cmd: 'npm',
args: ['run', 'build'],
cwd: path.dirname(__dirname) + '/core',
cwd: librariesDir + '/core',
});
}
@ -85,7 +86,7 @@ if (compile.iconify || compile.core) {
commands.push({
cmd: 'npm',
args: ['run', 'build'],
cwd: path.dirname(__dirname) + '/iconify',
cwd: librariesDir + '/iconify',
});
}
@ -127,7 +128,7 @@ next();
// Update version number in package.json
const packageJSON = JSON.parse(
fs.readFileSync(__dirname + '/package.json', 'utf8')
fs.readFileSync(testsDir + '/package.json', 'utf8')
);
let iconifyVersion = packageJSON.devDependencies['@iconify/iconify'].replace(
/[\^~]/g,
@ -137,7 +138,7 @@ if (packageJSON.version !== iconifyVersion) {
console.log('Updated package version to', iconifyVersion);
packageJSON.version = iconifyVersion;
fs.writeFileSync(
__dirname + '/package.json',
testsDir + '/package.json',
JSON.stringify(packageJSON, null, '\t') + '\n',
'utf8'
);

View File

@ -1,4 +1,4 @@
import { PendingQueryItem } from '@iconify/api-redundancy';
import { QueryModuleResponse } from '@iconify/api-redundancy';
import {
IconifyAPIIconsQueryParams,
IconifyAPIQueryParams,
@ -93,11 +93,11 @@ export const prepareQuery: IconifyAPIPrepareIconsQuery = (
export const sendQuery: IconifyAPISendQuery = (
host: string,
params: IconifyAPIQueryParams,
status: PendingQueryItem
callback: QueryModuleResponse
): void => {
if (params.type !== 'icons') {
// Fake API supports only icons
status.done(void 0, 400);
callback('abort', 400);
return;
}
@ -111,7 +111,7 @@ export const sendQuery: IconifyAPISendQuery = (
}
if (typeof data.host === 'string' && data.host !== host) {
// Host mismatch - send error (first parameter = undefined)
status.done(void 0, 404);
callback('abort', 404);
return;
}
@ -123,7 +123,7 @@ export const sendQuery: IconifyAPISendQuery = (
'", icons:',
icons
);
status.done(data.data);
callback('success', data.data);
};
if (!data.delay) {