Skip to content

Commit

Permalink
test(dotnet): change some "is built" imports to dynamic imports; remo…
Browse files Browse the repository at this point in the history
…ve "is exposed" tests

this will allow tests to run when the imports fail
  • Loading branch information
BinToss committed Sep 20, 2024
1 parent 9daf003 commit d64710c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
18 changes: 8 additions & 10 deletions tests/dotnet/MSBuildProject.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import {
MSBuildProject as exposed,
} from '@halospv3/hce.shared-config/dotnet/MSBuildProject'
import { deepStrictEqual, ok } from 'node:assert'
import { existsSync, readdirSync, rmSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
Expand All @@ -10,13 +7,14 @@ import {
MSBuildProject as MSBP,
} from '../../src/dotnet/MSBuildProject.js'

await describe('MSBuildProject', async (c00) => {
await it('is exposed', () => {
deepStrictEqual(exposed.name, c00.name)
})
await it('is built', () => {
deepStrictEqual(exposed, MSBP)
})
await it('is built', async () => {
deepStrictEqual(
Object.entries(await import('@halospv3/hce.shared-config/dotnet/MSBuildProject')),
Object.entries(await import('../../src/dotnet/MSBuildProject.js')),
)
})

await describe('MSBuildProject', async () => {
await describe('MatrixProperties', async (ctx1) => {
await it('has expected name', async () => {
ok(ctx1.name in MSBP)
Expand Down
14 changes: 7 additions & 7 deletions tests/dotnet/MSBuildProjectProperties.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { ok, strictEqual } from 'node:assert/strict'
import { describe, it } from 'node:test'
import { MSBuildProjectProperties as exposed } from '@halospv3/hce.shared-config/dotnet/MSBuildProjectProperties'
import { MSBuildProjectProperties as MPP } from '../../src/dotnet/MSBuildProjectProperties.js'
import { CaseInsensitiveMap } from './../../src/CaseInsensitiveMap.js'
import { deepStrictEqual } from 'node:assert'
import { tmpNameSync } from 'tmp'

await it('is built', async () => {
deepStrictEqual(
Object.entries(await import('@halospv3/hce.shared-config/dotnet/MSBuildProjectProperties')),
Object.entries(await import('../../src/dotnet/MSBuildProjectProperties.js')),
)
})

await describe('MSBuildProjectProperties', async (c0) => {
const emptyMap = new CaseInsensitiveMap<string, string>()
const emptySample = new MPP('', emptyMap)
Expand All @@ -25,12 +31,6 @@ await describe('MSBuildProjectProperties', async (c0) => {
await it('has expected name', () => {
strictEqual(MPP.name, c0.name)
})
await it('is exposed', () => {
ok(exposed)
})
await it('has been built', () => {
deepStrictEqual(MPP, exposed)
})
await it('has prototype', () => {
ok('prototype' in MPP)
})
Expand Down
11 changes: 7 additions & 4 deletions tests/dotnet/NugetProjectProperties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { describe, it } from 'node:test'
import { CaseInsensitiveMap } from '../../src/CaseInsensitiveMap.js'
import { NugetProjectProperties as NPP } from '../../src/dotnet/NugetProjectProperties.js'

await it('is built', async () => {
deepStrictEqual(
Object.entries(await import('../../src/dotnet/NugetProjectProperties.js')),
Object.entries(await import('@halospv3/hce.shared-config/dotnet/NugetProjectProperties')),
)
})

await describe('NugetProjectProperties', async (c0) => {
await it('has expected name', () => {
strictEqual(NPP.name, c0.name)
})
await it('exists', () => {
ok(NPP)
})
await it('is built', async () => {
const exposed = await import('@halospv3/hce.shared-config/dotnet/NugetProjectProperties')
deepStrictEqual(NPP, exposed)
})
await it('has prototype', () => {
ok('prototype' in NPP)
})
Expand Down
12 changes: 7 additions & 5 deletions tests/dotnet/NugetRegistryInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { MSBuildProject } from '../../src/dotnet/MSBuildProject.js'
import { NugetRegistryInfo as NRI } from '../../src/dotnet/NugetRegistryInfo.js'
import { resolve } from 'node:path'

await describe('NugetRegistryInfo', async (ctx0) => {
await it('is built', async () => {
const built = (await import('@halospv3/hce.shared-config/dotnet/NugetRegistryInfo')).NugetRegistryInfo
deepStrictEqual(built, NRI)
})
await it('is built', async () => {
deepStrictEqual(
Object.entries(await import('@halospv3/hce.shared-config/dotnet/NugetRegistryInfo')),
Object.entries(await import('../../src/dotnet/NugetRegistryInfo.js')),
)
})

await describe('NugetRegistryInfo', async (ctx0) => {
await it('is a class', async () => {
// bullshit, but that's how classes are implemented
deepStrictEqual(typeof NRI, 'function')
Expand Down
9 changes: 5 additions & 4 deletions tests/dotnet/dotnetHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
configureDotnetNugetPush,
configurePrepareCmd,
} from '../../src/dotnet/dotnetHelpers.js'
import * as built from '@halospv3/hce.shared-config/dotnet/dotnetHelpers'
import * as source from '../../src/dotnet/dotnetHelpers.js'

await it('is built', () => {
deepStrictEqual(built, source)
await it('is built', async () => {
deepStrictEqual(
Object.entries(await import('@halospv3/hce.shared-config/dotnet/dotnetHelpers')),
Object.entries(await import('../../src/dotnet/dotnetHelpers.js')),
)
})

await describe('dotnetHelpers', async () => {
Expand Down

0 comments on commit d64710c

Please sign in to comment.