Files
orca/config/scripts/orcad-distribution/server-bundle/orcad-mobile-web-bundle.test.mjs
OrcaWinandOrcaWin f865fb26a8 test: remove 141 low-value tests and 13 entire suites (#38613)
* test: remove server qualification inventories and mocked build tests

* test: remove packaging inventories and synthetic native tests

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-05 10:22:08 -08:00

44 lines
1.5 KiB
JavaScript

import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { ORCAD_MOBILE_WEB_MANIFEST } from '../../../../src/shared/orcad-artifacts.ts'
import { writeMobileWebBundleFixtureTree } from '../../build/mobile-web-app/mobile-web-bundle-fixture-tree.mjs'
import {
readOrcadMobileWebAssetFilenames,
stageOrcadMobileWebBundle
} from './orcad-mobile-web-bundle.mjs'
let scratch
let bundleDir
let outputDir
beforeEach(() => {
scratch = mkdtempSync(join(tmpdir(), 'orcad-mobile-web-'))
bundleDir = join(scratch, 'mobile-web')
outputDir = join(scratch, 'orcad')
vi.spyOn(console, 'log').mockImplementation(() => {})
})
afterEach(() => {
vi.restoreAllMocks()
vi.unstubAllEnvs()
rmSync(scratch, { recursive: true, force: true })
})
it('stages the manifest and every asset it lists, byte for byte', async () => {
const { manifest } = await writeMobileWebBundleFixtureTree({ outDir: bundleDir })
stageOrcadMobileWebBundle(outputDir, bundleDir)
const staged = readOrcadMobileWebAssetFilenames(outputDir)
expect(staged).toHaveLength(manifest.assets.length)
for (const asset of manifest.assets) {
expect(readFileSync(join(outputDir, 'out', 'mobile-web', asset.path))).toEqual(
readFileSync(join(bundleDir, asset.path))
)
}
expect(readFileSync(join(outputDir, ORCAD_MOBILE_WEB_MANIFEST))).toEqual(
readFileSync(join(bundleDir, 'manifest.json'))
)
})