2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-13 22:18:24 +00:00

tests: add dual jest test, esm and cjs working

This commit is contained in:
Joaquín Sánchez Jiménez 2022-03-04 00:36:30 +01:00
parent 7ba8d5a2be
commit ae3706cbf8
11 changed files with 361 additions and 76 deletions

View File

@ -1,7 +1,20 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
/*
module.exports = { module.exports = {
verbose: true, verbose: true,
preset: 'ts-jest', preset: 'ts-jest',
testEnvironment: 'node', testEnvironment: 'node',
testMatch: ['**/tests/*-test.ts'], testMatch: ['**!/tests/!*-test.ts'],
}; };
*/
import { buildConfiguration } from './jest.shared.config'
export default buildConfiguration({
moduleFileExtensions: ['ts', 'cjs', 'js'],
globals: {
'ts-jest': {
useESM: false,
},
},
})

View File

@ -1,7 +0,0 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/tests/*-test.ts'],
};

View File

@ -1,7 +1,10 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ import { buildConfiguration } from './jest.shared.config'
module.exports = {
verbose: true, export default buildConfiguration({
preset: 'ts-jest', moduleFileExtensions: ['ts', 'mjs', 'js'],
testEnvironment: 'node', globals: {
testMatch: ['**/tests/*-test.ts'], 'ts-jest': {
}; useESM: true,
},
},
})

View File

@ -0,0 +1,21 @@
import type { Config } from '@jest/types'
// see https://jestjs.io/docs/ecmascript-modules
export const buildConfiguration = (configuration: Partial<Config.InitialOptions>): Config.InitialOptions => {
return Object.assign({}, {
verbose: true,
testEnvironment: 'node',
moduleDirectories: [
'node_modules',
'src',
],
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
testMatch: [
'**/tests/*-test.ts',
],
}, configuration)
}

View File

@ -29,6 +29,7 @@
"jest": "^27.2.1", "jest": "^27.2.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"ts-node": "^10.6.0",
"typescript": "^4.4.3", "typescript": "^4.4.3",
"unbuild": "^0.6.9" "unbuild": "^0.6.9"
} }
@ -702,6 +703,27 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true "dev": true
}, },
"node_modules/@cspotcode/source-map-consumer": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
"integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==",
"dev": true,
"engines": {
"node": ">= 12"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz",
"integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==",
"dev": true,
"dependencies": {
"@cspotcode/source-map-consumer": "0.8.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@eslint/eslintrc": { "node_modules/@eslint/eslintrc": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
@ -1374,6 +1396,30 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/@tsconfig/node10": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz",
"integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==",
"dev": true
},
"node_modules/@tsconfig/node12": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz",
"integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==",
"dev": true
},
"node_modules/@tsconfig/node14": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz",
"integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==",
"dev": true
},
"node_modules/@tsconfig/node16": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz",
"integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==",
"dev": true
},
"node_modules/@types/babel__core": { "node_modules/@types/babel__core": {
"version": "7.1.16", "version": "7.1.16",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz",
@ -1836,6 +1882,12 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"dev": true
},
"node_modules/argparse": { "node_modules/argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@ -2221,6 +2273,12 @@
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true "dev": true
}, },
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true
},
"node_modules/cross-env": { "node_modules/cross-env": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@ -2357,6 +2415,15 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true,
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/diff-sequences": { "node_modules/diff-sequences": {
"version": "27.0.6", "version": "27.0.6",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.6.tgz", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.6.tgz",
@ -5896,6 +5963,69 @@
} }
} }
}, },
"node_modules/ts-node": {
"version": "10.6.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.6.0.tgz",
"integrity": "sha512-CJen6+dfOXolxudBQXnVjRVvYTmTWbyz7cn+xq2XTsvnaXbHqr4gXSCNbS2Jj8yTZMuGwUoBESLaOkLascVVvg==",
"dev": true,
"dependencies": {
"@cspotcode/source-map-support": "0.7.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.0",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/ts-node/node_modules/acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"dev": true,
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/ts-node/node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true,
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "1.14.1", "version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
@ -6371,6 +6501,12 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true "dev": true
}, },
"node_modules/v8-compile-cache-lib": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz",
"integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==",
"dev": true
},
"node_modules/v8-to-istanbul": { "node_modules/v8-to-istanbul": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz",
@ -6595,6 +6731,15 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true,
"engines": {
"node": ">=6"
}
},
"node_modules/yocto-queue": { "node_modules/yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
@ -7120,6 +7265,21 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true "dev": true
}, },
"@cspotcode/source-map-consumer": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
"integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==",
"dev": true
},
"@cspotcode/source-map-support": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz",
"integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==",
"dev": true,
"requires": {
"@cspotcode/source-map-consumer": "0.8.0"
}
},
"@eslint/eslintrc": { "@eslint/eslintrc": {
"version": "0.4.3", "version": "0.4.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz",
@ -7659,6 +7819,30 @@
"integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==",
"dev": true "dev": true
}, },
"@tsconfig/node10": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz",
"integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==",
"dev": true
},
"@tsconfig/node12": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz",
"integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==",
"dev": true
},
"@tsconfig/node14": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz",
"integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==",
"dev": true
},
"@tsconfig/node16": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz",
"integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==",
"dev": true
},
"@types/babel__core": { "@types/babel__core": {
"version": "7.1.16", "version": "7.1.16",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz",
@ -8004,6 +8188,12 @@
"picomatch": "^2.0.4" "picomatch": "^2.0.4"
} }
}, },
"arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"dev": true
},
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@ -8310,6 +8500,12 @@
} }
} }
}, },
"create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true
},
"cross-env": { "cross-env": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@ -8413,6 +8609,12 @@
"integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==",
"dev": true "dev": true
}, },
"diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true
},
"diff-sequences": { "diff-sequences": {
"version": "27.0.6", "version": "27.0.6",
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.6.tgz", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.6.tgz",
@ -11010,6 +11212,41 @@
"yargs-parser": "20.x" "yargs-parser": "20.x"
} }
}, },
"ts-node": {
"version": "10.6.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.6.0.tgz",
"integrity": "sha512-CJen6+dfOXolxudBQXnVjRVvYTmTWbyz7cn+xq2XTsvnaXbHqr4gXSCNbS2Jj8yTZMuGwUoBESLaOkLascVVvg==",
"dev": true,
"requires": {
"@cspotcode/source-map-support": "0.7.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.0",
"yn": "3.1.1"
},
"dependencies": {
"acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"dev": true
},
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"dev": true
}
}
},
"tslib": { "tslib": {
"version": "1.14.1", "version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
@ -11283,6 +11520,12 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true "dev": true
}, },
"v8-compile-cache-lib": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz",
"integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==",
"dev": true
},
"v8-to-istanbul": { "v8-to-istanbul": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz",
@ -11456,6 +11699,12 @@
"integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
"dev": true "dev": true
}, },
"yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true
},
"yocto-queue": { "yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View File

@ -1,6 +1,5 @@
{ {
"name": "@iconify/utils", "name": "@iconify/utils",
"type": "module",
"description": "Common functions for working with Iconify icon sets used by various packages.", "description": "Common functions for working with Iconify icon sets used by various packages.",
"author": "Vjacheslav Trushkin", "author": "Vjacheslav Trushkin",
"version": "1.0.23", "version": "1.0.23",
@ -20,9 +19,12 @@
"build-dual": "unbuild", "build-dual": "unbuild",
"test:jest": "jest --runInBand", "test:jest": "jest --runInBand",
"test:jasmine": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jasmine", "test:jasmine": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jasmine",
"test": "npm run test:jest && npm run test:jasmine" "test": "npm run test:jest && npm run test:jasmine",
}, "test:jest-esm": "npm run build-dual && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.esm.config.ts",
"sideEffects": false, "test:jest-cjs": "npm run build-dual && jest --clearCache && jest --config=jest.cjs.config.ts",
"test-dual": "npm run test:jest-esm && npm run test:jest-cjs && npm run test:jasmine"
},
"sideEffects": false,
"exports": { "exports": {
".": { ".": {
"require": "./lib/index.cjs", "require": "./lib/index.cjs",
@ -127,13 +129,13 @@
"./lib/loader/fs": { "./lib/loader/fs": {
"require": "./lib/loader/fs.cjs", "require": "./lib/loader/fs.cjs",
"import": "./lib/loader/fs.mjs", "import": "./lib/loader/fs.mjs",
"types": "./lib/loader/fs.d.ts" "types": "./lib/loader/fs.d.ts"
}, },
"./lib/loader/install-pkg": { "./lib/loader/install-pkg": {
"require": "./lib/loader/install-pkg.cjs", "require": "./lib/loader/install-pkg.cjs",
"import": "./lib/loader/install-pkg.mjs", "import": "./lib/loader/install-pkg.mjs",
"types": "./lib/loader/install-pkg.d.ts" "types": "./lib/loader/install-pkg.d.ts"
}, },
"./lib/loader/loader": { "./lib/loader/loader": {
"require": "./lib/loader/loader.cjs", "require": "./lib/loader/loader.cjs",
"import": "./lib/loader/loader.mjs" "import": "./lib/loader/loader.mjs"
@ -142,16 +144,16 @@
"require": "./lib/loader/modern.cjs", "require": "./lib/loader/modern.cjs",
"import": "./lib/loader/modern.mjs" "import": "./lib/loader/modern.mjs"
}, },
"./lib/loader/node-loader": { "./lib/loader/node-loader": {
"require": "./lib/loader/node-loader.cjs", "require": "./lib/loader/node-loader.cjs",
"import": "./lib/loader/node-loader.mjs", "import": "./lib/loader/node-loader.mjs",
"types": "./lib/loader/node-loader.d.ts" "types": "./lib/loader/node-loader.d.ts"
}, },
"./lib/loader/node-loaders": { "./lib/loader/node-loaders": {
"require": "./lib/loader/node-loaders.cjs", "require": "./lib/loader/node-loaders.cjs",
"import": "./lib/loader/node-loaders.mjs", "import": "./lib/loader/node-loaders.mjs",
"types": "./lib/loader/node-loaders.d.ts" "types": "./lib/loader/node-loaders.d.ts"
}, },
"./lib/loader/types": { "./lib/loader/types": {
"require": "./lib/loader/types.cjs", "require": "./lib/loader/types.cjs",
"import": "./lib/loader/types.mjs" "import": "./lib/loader/types.mjs"
@ -159,12 +161,12 @@
"./lib/loader/utils": { "./lib/loader/utils": {
"require": "./lib/loader/utils.cjs", "require": "./lib/loader/utils.cjs",
"import": "./lib/loader/utils.mjs" "import": "./lib/loader/utils.mjs"
}, },
"./lib/loader/warn": { "./lib/loader/warn": {
"require": "./lib/loader/warn.cjs", "require": "./lib/loader/warn.cjs",
"import": "./lib/loader/warn.mjs", "import": "./lib/loader/warn.mjs",
"types": "./lib/loader/warn.d.ts" "types": "./lib/loader/warn.d.ts"
}, },
"./lib/misc/strings": { "./lib/misc/strings": {
"require": "./lib/misc/strings.cjs", "require": "./lib/misc/strings.cjs",
"import": "./lib/misc/strings.mjs" "import": "./lib/misc/strings.mjs"
@ -184,30 +186,30 @@
"./lib/svg/size": { "./lib/svg/size": {
"require": "./lib/svg/size.cjs", "require": "./lib/svg/size.cjs",
"import": "./lib/svg/size.mjs" "import": "./lib/svg/size.mjs"
}, },
"./*": "./*" "./*": "./*"
}, },
"main": "lib/index.cjs", "main": "lib/index.cjs",
"module": "lib/index.mjs", "module": "lib/index.mjs",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
"files": [ "files": [
"lib", "lib",
"lib/colors", "lib/colors",
"lib/customisations", "lib/customisations",
"lib/icon", "lib/icon",
"lib/icon-set", "lib/icon-set",
"lib/loader", "lib/loader",
"lib/misc", "lib/misc",
"lib/svg", "lib/svg",
"*.d.ts" "*.d.ts"
], ],
"dependencies": { "dependencies": {
"@antfu/install-pkg": "^0.1.0", "@antfu/install-pkg": "^0.1.0",
"@antfu/utils": "^0.3.0", "@antfu/utils": "^0.3.0",
"@iconify/types": "^1.0.12", "@iconify/types": "^1.0.12",
"debug": "^4.3.3", "debug": "^4.3.3",
"kolorist": "^1.5.0", "kolorist": "^1.5.0",
"local-pkg": "^0.4.0" "local-pkg": "^0.4.0"
}, },
"devDependencies": { "devDependencies": {
"@iconify-json/flat-color-icons": "^1.0.2", "@iconify-json/flat-color-icons": "^1.0.2",
@ -222,6 +224,7 @@
"jest": "^27.2.1", "jest": "^27.2.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"ts-node": "^10.6.0",
"typescript": "^4.4.3", "typescript": "^4.4.3",
"unbuild": "^0.6.9" "unbuild": "^0.6.9"
} }

View File

@ -1,8 +1,10 @@
import { FileSystemIconLoader } from '../lib'; import { FileSystemIconLoader } from '../lib/loader/node-loaders';
const fixturesDir = './tests/fixtures';
describe('Testing FileSystemIconLoader', () => { describe('Testing FileSystemIconLoader', () => {
test('FileSystemIconLoader', async () => { test('FileSystemIconLoader', async () => {
const result = await FileSystemIconLoader(__dirname + '/fixtures')( const result = await FileSystemIconLoader(fixturesDir)(
'circle' 'circle'
); );
expect(result && result.indexOf('svg') > -1).toBeTruthy(); expect(result && result.indexOf('svg') > -1).toBeTruthy();
@ -10,7 +12,7 @@ describe('Testing FileSystemIconLoader', () => {
test('FileSystemIconLoader with transform', async () => { test('FileSystemIconLoader with transform', async () => {
const result = await FileSystemIconLoader( const result = await FileSystemIconLoader(
__dirname + '/fixtures', fixturesDir,
(icon) => { (icon) => {
return icon.replace('<svg ', '<svg width="1em" height="1em" '); return icon.replace('<svg ', '<svg width="1em" height="1em" ');
} }

View File

@ -1,7 +1,7 @@
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { getCustomIcon } from '../lib'; import { getCustomIcon } from '../lib';
const fixturesDir = __dirname + '/fixtures'; const fixturesDir = './tests/fixtures';
describe('Testing getCustomIcon', () => { describe('Testing getCustomIcon', () => {
test('CustomIconLoader', async () => { test('CustomIconLoader', async () => {

View File

@ -1,20 +1,20 @@
import { loadIcon } from '../lib'; import { loadNodeIcon } from '../lib/loader/node-loader';
describe('Testing loadIcon with @iconify-json/flat-color-icons>', () => { describe('Testing loadIcon with @iconify-json/flat-color-icons>', () => {
test('loadIcon works', async () => { test('loadIcon works', async () => {
const result = await loadIcon('flat-color-icons', 'up-right'); const result = await loadNodeIcon('flat-color-icons', 'up-right');
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
test('loadIcon adds xmlns:xlink', async () => { test('loadIcon adds xmlns:xlink', async () => {
const result = await loadIcon('flat-color-icons', 'up-right', { addXmlNs: true }); const result = await loadNodeIcon('flat-color-icons', 'up-right', { addXmlNs: true });
expect(result).toBeTruthy(); expect(result).toBeTruthy();
expect(result && result.indexOf('xmlns:xlink=') > - 1).toBeTruthy(); expect(result && result.indexOf('xmlns:xlink=') > - 1).toBeTruthy();
}); });
test('loadIcon with customize with default style and class', async () => { test('loadIcon with customize with default style and class', async () => {
const result = await loadIcon('flat-color-icons', 'up-right', { const result = await loadNodeIcon('flat-color-icons', 'up-right', {
defaultStyle: 'margin-top: 1rem;', defaultStyle: 'margin-top: 1rem;',
defaultClass: 'clazz', defaultClass: 'clazz',
customizations: { customizations: {
@ -33,7 +33,7 @@ describe('Testing loadIcon with @iconify-json/flat-color-icons>', () => {
}); });
test('loadIcon preserves customizations order', async () => { test('loadIcon preserves customizations order', async () => {
const result = await loadIcon('flat-color-icons', 'up-right', { const result = await loadNodeIcon('flat-color-icons', 'up-right', {
scale: 1, scale: 1,
defaultStyle: 'color: red;', defaultStyle: 'color: red;',
defaultClass: 'clazz1', defaultClass: 'clazz1',

View File

@ -1,7 +1,8 @@
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { CustomIconLoader, loadIcon } from '../lib'; import type { CustomIconLoader } from '../lib';
import { loadIcon } from '../lib';
const fixturesDir = __dirname + '/fixtures'; const fixturesDir = './tests/fixtures';
const loader: CustomIconLoader = async(name) => { const loader: CustomIconLoader = async(name) => {
return await fs.readFile(`${fixturesDir}/${name}.svg`, 'utf8'); return await fs.readFile(`${fixturesDir}/${name}.svg`, 'utf8');

View File

@ -1,5 +1,5 @@
{ {
"extends": "../tsconfig-base.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"types": ["node", "jest"], "types": ["node", "jest"],
"rootDir": ".", "rootDir": ".",