mirror of
https://github.com/iconify/collections-json.git
synced 2024-11-21 12:05:11 +00:00
test: hacking cjs tests
chore: modify target and module on tsconfig configuration
This commit is contained in:
parent
233e4ddcfd
commit
08c5ce10f7
@ -1,7 +1,12 @@
|
||||
import config from './jest/jest.shared.config'
|
||||
import { buildConfiguration } from './jest/jest.shared.config'
|
||||
|
||||
config.testMatch = [
|
||||
'**/?(*.)+(cjs).+(spec|test).+(ts|tsx|js)',
|
||||
]
|
||||
|
||||
export default config
|
||||
export default buildConfiguration({
|
||||
testMatch: [
|
||||
'**/?(*.)+(cjs).+(spec|test).+(ts|tsx|js)',
|
||||
],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
useESM: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -1,12 +1,12 @@
|
||||
import config from './jest/jest.shared.config'
|
||||
import { buildConfiguration } from './jest/jest.shared.config'
|
||||
|
||||
config.testMatch = [
|
||||
'**/?(*.)+(esm).+(spec|test).+(ts|tsx|js)',
|
||||
]
|
||||
config.globals = {
|
||||
'ts-jest': {
|
||||
useESM: true,
|
||||
export default buildConfiguration({
|
||||
testMatch: [
|
||||
'**/?(*.)+(esm).+(spec|test).+(ts|tsx|js)',
|
||||
],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
useESM: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
})
|
||||
|
@ -2,18 +2,17 @@ import type { Config } from '@jest/types'
|
||||
|
||||
// see https://jestjs.io/docs/ecmascript-modules
|
||||
|
||||
// Sync object
|
||||
const config: Config.InitialOptions = {
|
||||
verbose: true,
|
||||
moduleDirectories: [
|
||||
'node_modules',
|
||||
'src',
|
||||
],
|
||||
moduleFileExtensions: ['ts', 'js'],
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
export const buildConfiguration = (configuration: Partial<Config.InitialOptions>): Config.InitialOptions => {
|
||||
return Object.assign({}, {
|
||||
verbose: true,
|
||||
moduleDirectories: [
|
||||
'node_modules',
|
||||
'src',
|
||||
],
|
||||
moduleFileExtensions: ['ts', 'js'],
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
}, configuration)
|
||||
}
|
||||
|
||||
export default config
|
||||
|
@ -15,7 +15,7 @@
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"files": [
|
||||
"dist",
|
||||
"json",
|
||||
"lib",
|
||||
|
@ -1,27 +1,4 @@
|
||||
import { IconifyMetaDataCollection, lookupCollection, lookupCollections } from '../dist'
|
||||
import { lookupCollection, lookupCollections } from '../dist'
|
||||
import { lookupCollectionTest } from './loadCollection.test'
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
lookupCollectionTest(lookupCollection, lookupCollections)
|
||||
|
@ -1,27 +1,4 @@
|
||||
import { IconifyMetaDataCollection, lookupCollection, lookupCollections } from '.'
|
||||
import { lookupCollectionTest } from './loadCollection.test'
|
||||
import { 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')
|
||||
})
|
||||
})
|
||||
lookupCollectionTest(lookupCollection, lookupCollections)
|
||||
|
32
src/loadCollection.test.ts
Normal file
32
src/loadCollection.test.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import type { IconifyMetaDataCollection } from '.'
|
||||
import { IconifyJSON } from '.'
|
||||
|
||||
export const lookupCollectionTest = (
|
||||
lookupCollection: (name: string) => Promise<IconifyJSON>,
|
||||
lookupCollections: () => Promise<IconifyMetaDataCollection>,
|
||||
) => {
|
||||
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')
|
||||
})
|
||||
})
|
||||
}
|
@ -1,10 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { locate } from '../dist'
|
||||
import { locateTest } from './locate.test'
|
||||
|
||||
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)
|
||||
})
|
||||
locateTest(locate)
|
||||
|
@ -1,10 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { locateTest } from './locate.test'
|
||||
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)
|
||||
})
|
||||
locateTest(locate)
|
||||
|
12
src/locate.test.ts
Normal file
12
src/locate.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { resolve } from 'path'
|
||||
import { PathLike } from 'fs'
|
||||
|
||||
const cwd = process.cwd()
|
||||
|
||||
export const locateTest = (locate: (name: string) => PathLike) => {
|
||||
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,8 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"module": "esnext",
|
||||
"target": "ESNext",
|
||||
"target": "es2017",
|
||||
"module": "ESNext",
|
||||
"lib": ["ESNext"],
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
|
Loading…
Reference in New Issue
Block a user