mirror of
https://github.com/iconify/collections-json.git
synced 2024-11-21 12:05:11 +00:00
test: esm and cjs tests
This commit is contained in:
parent
7898d72798
commit
233e4ddcfd
7
jest.cjs.config.ts
Normal file
7
jest.cjs.config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import config from './jest/jest.shared.config'
|
||||
|
||||
config.testMatch = [
|
||||
'**/?(*.)+(cjs).+(spec|test).+(ts|tsx|js)',
|
||||
]
|
||||
|
||||
export default config
|
@ -1,9 +0,0 @@
|
||||
import config from './jest.config.cjs'
|
||||
|
||||
config.globals = {
|
||||
'ts-jest': {
|
||||
useESM: true,
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
12
jest.esm.config.ts
Normal file
12
jest.esm.config.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import config from './jest/jest.shared.config'
|
||||
|
||||
config.testMatch = [
|
||||
'**/?(*.)+(esm).+(spec|test).+(ts|tsx|js)',
|
||||
]
|
||||
config.globals = {
|
||||
'ts-jest': {
|
||||
useESM: true,
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
@ -5,10 +5,6 @@ import type { Config } from '@jest/types'
|
||||
// Sync object
|
||||
const config: Config.InitialOptions = {
|
||||
verbose: true,
|
||||
testMatch: [
|
||||
'**/__tests__/**/*.+(ts|tsx|js)',
|
||||
'**/?(*.)+(spec|test).+(ts|tsx|js)',
|
||||
],
|
||||
moduleDirectories: [
|
||||
'node_modules',
|
||||
'src',
|
20
package.json
20
package.json
@ -1,13 +1,21 @@
|
||||
{
|
||||
"name": "@iconify/json",
|
||||
"description": "Iconify icons collection in JSON format",
|
||||
"license": "MIT",
|
||||
"version": "1.1.401",
|
||||
"description": "Iconify icons collection in JSON format",
|
||||
"homepage": "https://iconify.design/icon-sets/",
|
||||
"bugs": "https://github.com/iconify/collections-json/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/iconify/collections-json.git"
|
||||
},
|
||||
"files": [
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"json",
|
||||
"lib",
|
||||
@ -19,12 +27,10 @@
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"homepage": "https://iconify.design/icon-sets/",
|
||||
"bugs": "https://github.com/iconify/collections-json/issues",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts",
|
||||
"test-esm": "yarn build && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.config.esm.ts",
|
||||
"test-cjs": "yarn build && jest --clearCache && jest --config=jest.config.cjs.ts"
|
||||
"test-esm": "jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.esm.config.ts",
|
||||
"test-cjs": "yarn build && jest --clearCache && jest --config=jest.cjs.config.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"upath": "^2.0.1"
|
||||
|
@ -10,7 +10,9 @@
|
||||
*/
|
||||
import { PathLike, promises as fs } from 'fs'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname, resolve } from 'upath'
|
||||
import Upath from 'upath'
|
||||
|
||||
const { dirname, resolve } = Upath
|
||||
|
||||
/**
|
||||
* Icon dimensions.
|
||||
|
27
src/loadCollection.esm.test.ts
Normal file
27
src/loadCollection.esm.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { IconifyMetaDataCollection, lookupCollection, lookupCollections } from '.'
|
||||
|
||||
let collections: IconifyMetaDataCollection
|
||||
|
||||
describe('lookupCollection and lookupCollections', () => {
|
||||
beforeAll(() => {
|
||||
return lookupCollections().then((c) => {
|
||||
collections = c
|
||||
return Promise.resolve(c)
|
||||
})
|
||||
})
|
||||
test('lookupCollections has data', () => {
|
||||
expect(collections ? Object.keys(collections).length : 0).toBeGreaterThan(0)
|
||||
})
|
||||
test('mdi collection has prefix mdi', async() => {
|
||||
const collection = await lookupCollection('mdi')
|
||||
expect(collection.prefix).toBe('mdi')
|
||||
})
|
||||
test('websymbol collection has prefix websymbol', async() => {
|
||||
const collection = await lookupCollection('websymbol')
|
||||
expect(collection.prefix).toBe('websymbol')
|
||||
})
|
||||
test('fa collection has prefix fa', async() => {
|
||||
const collection = await lookupCollection('fa')
|
||||
expect(collection.prefix).toBe('fa')
|
||||
})
|
||||
})
|
10
src/locate.esm.test.ts
Normal file
10
src/locate.esm.test.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { resolve } from 'path'
|
||||
import { locate } from '.'
|
||||
|
||||
const cwd = process.cwd()
|
||||
|
||||
test('mdi resolves the json collection', () => {
|
||||
const received = locate('mdi') as string
|
||||
const expected = resolve(cwd, 'json', 'mdi.json').replace(/\\/g, '/')
|
||||
expect(received).toBe(expected)
|
||||
})
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"module": "ESNext",
|
||||
"module": "esnext",
|
||||
"target": "ESNext",
|
||||
"lib": ["ESNext"],
|
||||
"esModuleInterop": true,
|
||||
|
Loading…
Reference in New Issue
Block a user