30 行
1.3 KiB
JavaScript
30 行
1.3 KiB
JavaScript
|
|
import assert from 'node:assert/strict'
|
||
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||
|
|
import { tmpdir } from 'node:os'
|
||
|
|
import path from 'node:path'
|
||
|
|
import test from 'node:test'
|
||
|
|
import { computeNativeBaseline } from './native-baseline.mjs'
|
||
|
|
|
||
|
|
function fixture() {
|
||
|
|
const root = mkdtempSync(path.join(tmpdir(), 'xuqm-native-baseline-'))
|
||
|
|
mkdirSync(path.join(root, 'android', 'app', 'src', 'main', 'java'), { recursive: true })
|
||
|
|
mkdirSync(path.join(root, 'src'), { recursive: true })
|
||
|
|
writeFileSync(path.join(root, 'package.json'), JSON.stringify({ dependencies: {} }))
|
||
|
|
writeFileSync(path.join(root, 'android', 'settings.gradle'), 'rootProject.name = "fixture"')
|
||
|
|
writeFileSync(path.join(root, 'src', 'business.ts'), 'export const value = 1')
|
||
|
|
return root
|
||
|
|
}
|
||
|
|
|
||
|
|
test('native source changes the baseline while ordinary JS does not', () => {
|
||
|
|
const root = fixture()
|
||
|
|
try {
|
||
|
|
const initial = computeNativeBaseline(root)
|
||
|
|
writeFileSync(path.join(root, 'src', 'business.ts'), 'export const value = 2')
|
||
|
|
assert.equal(computeNativeBaseline(root), initial)
|
||
|
|
writeFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'Main.kt'), 'class Main')
|
||
|
|
assert.notEqual(computeNativeBaseline(root), initial)
|
||
|
|
} finally {
|
||
|
|
rmSync(root, { recursive: true, force: true })
|
||
|
|
}
|
||
|
|
})
|