mirror of
https://github.com/iconify/collections-json.git
synced 2024-11-10 15:20:58 +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 = [
|
export default buildConfiguration({
|
||||||
|
testMatch: [
|
||||||
'**/?(*.)+(cjs).+(spec|test).+(ts|tsx|js)',
|
'**/?(*.)+(cjs).+(spec|test).+(ts|tsx|js)',
|
||||||
]
|
],
|
||||||
|
globals: {
|
||||||
export default config
|
'ts-jest': {
|
||||||
|
useESM: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import config from './jest/jest.shared.config'
|
import { buildConfiguration } from './jest/jest.shared.config'
|
||||||
|
|
||||||
config.testMatch = [
|
export default buildConfiguration({
|
||||||
|
testMatch: [
|
||||||
'**/?(*.)+(esm).+(spec|test).+(ts|tsx|js)',
|
'**/?(*.)+(esm).+(spec|test).+(ts|tsx|js)',
|
||||||
]
|
],
|
||||||
config.globals = {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
useESM: true,
|
useESM: true,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
})
|
||||||
export default config
|
|
||||||
|
@ -2,8 +2,8 @@ import type { Config } from '@jest/types'
|
|||||||
|
|
||||||
// see https://jestjs.io/docs/ecmascript-modules
|
// see https://jestjs.io/docs/ecmascript-modules
|
||||||
|
|
||||||
// Sync object
|
export const buildConfiguration = (configuration: Partial<Config.InitialOptions>): Config.InitialOptions => {
|
||||||
const config: Config.InitialOptions = {
|
return Object.assign({}, {
|
||||||
verbose: true,
|
verbose: true,
|
||||||
moduleDirectories: [
|
moduleDirectories: [
|
||||||
'node_modules',
|
'node_modules',
|
||||||
@ -14,6 +14,5 @@ const config: Config.InitialOptions = {
|
|||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest',
|
'^.+\\.ts$': 'ts-jest',
|
||||||
},
|
},
|
||||||
|
}, configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default config
|
|
||||||
|
@ -1,27 +1,4 @@
|
|||||||
import { IconifyMetaDataCollection, lookupCollection, lookupCollections } from '../dist'
|
import { lookupCollection, lookupCollections } from '../dist'
|
||||||
|
import { lookupCollectionTest } from './loadCollection.test'
|
||||||
|
|
||||||
let collections: IconifyMetaDataCollection
|
lookupCollectionTest(lookupCollection, lookupCollections)
|
||||||
|
|
||||||
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,27 +1,4 @@
|
|||||||
import { IconifyMetaDataCollection, lookupCollection, lookupCollections } from '.'
|
import { lookupCollectionTest } from './loadCollection.test'
|
||||||
|
import { lookupCollection, lookupCollections } from '.'
|
||||||
|
|
||||||
let collections: IconifyMetaDataCollection
|
lookupCollectionTest(lookupCollection, lookupCollections)
|
||||||
|
|
||||||
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')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
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 { locate } from '../dist'
|
||||||
|
import { locateTest } from './locate.test'
|
||||||
|
|
||||||
const cwd = process.cwd()
|
locateTest(locate)
|
||||||
|
|
||||||
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,10 +1,4 @@
|
|||||||
import { resolve } from 'path'
|
import { locateTest } from './locate.test'
|
||||||
import { locate } from '.'
|
import { locate } from '.'
|
||||||
|
|
||||||
const cwd = process.cwd()
|
locateTest(locate)
|
||||||
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
|
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": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"target": "es2017",
|
||||||
"module": "esnext",
|
"module": "ESNext",
|
||||||
"target": "ESNext",
|
|
||||||
"lib": ["ESNext"],
|
"lib": ["ESNext"],
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user