Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Oct 14, 2024
1 parent 8bb7c7a commit f2602f3
Showing 1 changed file with 230 additions and 0 deletions.
230 changes: 230 additions & 0 deletions packages/assetpack/test/manifest/Manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,236 @@ describe('Manifest', () =>
});
});

it('should ensure sub-manifests are created correctly with short names', async () =>
{
const testName = 'manifest-sub-manifest-short';
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

createFolder(pkg, {
name: testName,
files: [],
folders: [
{
name: 'sound{m}',
files: [
{
name: '1.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [],
},
{
name: 'sound2{m}',
files: [
{
name: '2.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [],
},
{
name: 'sound3{m}',
files: [
{
name: '3.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [
{
name: 'sound2{m}',
files: [
{
name: '2.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [],
},
],
},
],
});

const assetpack = new AssetPack({
entry: inputDir,
cacheLocation: getCacheDir(pkg, testName),
output: outputDir,
cache: false,
pipes: [
pixiManifest({
includeMetaData: false,
}),
],
});

await assetpack.run();

expect(fs.readJSONSync(`${outputDir}/manifest.json`)).toEqual({
bundles: [
{
name: 'default',
assets: [],
},
{
name: 'sound2',
assets: [
{
alias: ['sound2/2.mp3'],
src: ['sound2/2.mp3'],
},
],
},
{
name: 'sound3',
assets: [
{
alias: ['sound3/3.mp3'],
src: ['sound3/3.mp3'],
},
],
},
{
name: 'sound3/sound2',
assets: [
{
alias: ['sound3/sound2/2.mp3'],
src: ['sound3/sound2/2.mp3'],
},
],
},
{
name: 'sound',
assets: [
{
alias: ['sound/1.mp3'],
src: ['sound/1.mp3'],
},
],
},
],
});
});

it('should ensure sub-manifests are created correctly with relative names', async () =>
{
const testName = 'manifest-sub-manifest-relative';
const inputDir = getInputDir(pkg, testName);
const outputDir = getOutputDir(pkg, testName);

createFolder(pkg, {
name: testName,
files: [],
folders: [
{
name: 'sound{m}',
files: [
{
name: '1.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [
{
name: 'sound2{m}',
files: [
{
name: '2.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [],
},
],
},
{
name: 'sound3{m}',
files: [
{
name: '3.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [
{
name: 'sound2{m}',
files: [
{
name: '2.mp3',
content: assetPath('audio/1.mp3'),
},
],
folders: [],
},
],
},
],
});

const assetpack = new AssetPack({
entry: inputDir,
cacheLocation: getCacheDir(pkg, testName),
output: outputDir,
cache: false,
pipes: [
pixiManifest({
includeMetaData: false,
nameStyle: 'relative',
}),
],
});

await assetpack.run();

expect(fs.readJSONSync(`${outputDir}/manifest.json`)).toEqual({
bundles: [
{
name: 'default',
assets: [],
},
{
name: 'sound3',
assets: [
{
alias: ['sound3/3.mp3'],
src: ['sound3/3.mp3'],
},
],
},
{
name: 'sound3/sound2',
assets: [
{
alias: ['sound3/sound2/2.mp3'],
src: ['sound3/sound2/2.mp3'],
},
],
},
{
name: 'sound',
assets: [
{
alias: ['sound/1.mp3'],
src: ['sound/1.mp3'],
},
],
},
{
name: 'sound/sound2',
assets: [
{
alias: ['sound/sound2/2.mp3'],
src: ['sound/sound2/2.mp3'],
},
],
},
],
});
});

it('should ignore files with the mIgnore tag', async () =>
{
const testName = 'manifest-ignore';
Expand Down

0 comments on commit f2602f3

Please sign in to comment.