Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { StreamedFile } from '@php-wasm/stream-compression';
import { RecommendedPHPVersion } from '@wp-playground/common';
import { resolveRuntimeConfiguration } from '../../lib/resolve-runtime-configuration';
import type { BlueprintBundle } from '../../lib/types';
import type { BlueprintV2Declaration } from '../../lib/v2/blueprint-v2-declaration';

describe('Blueprint v2 runtime configuration', () => {
const expectedDefaults = {
phpVersion: RecommendedPHPVersion,
wpVersion: 'latest',
intl: false,
networking: true,
constants: {},
extraLibraries: [],
};

it('resolves default runtime configuration from a declaration', async () => {
const blueprint = {
version: 2,
} satisfies BlueprintV2Declaration;

await expect(resolveRuntimeConfiguration(blueprint)).resolves.toEqual(
expectedDefaults
);
});

it('resolves default runtime configuration from a bundle declaration', async () => {
const blueprint = createBundle({
version: 2,
});

await expect(resolveRuntimeConfiguration(blueprint)).resolves.toEqual(
expectedDefaults
);
});
});

function createBundle(blueprint: BlueprintV2Declaration): BlueprintBundle {
return {
async read(path: string) {
if (path !== 'blueprint.json') {
throw new Error(`Unexpected bundle read: ${path}`);
}
return StreamedFile.fromArrayBuffer(
new TextEncoder().encode(JSON.stringify(blueprint)),
'blueprint.json'
);
},
} satisfies BlueprintBundle;
}
Loading