forked from pixijs/assetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -631,11 +631,11 @@ describe('Manifest', () => | |
], | ||
}, | ||
{ | ||
alias: ['folder2/1.mp3', '1.mp3'], | ||
alias: ['folder2/1.mp3'], | ||
src: ['folder2/1.ogg', 'folder2/1.mp3'], | ||
}, | ||
{ | ||
alias: ['folder2/folder3/1.mp3', '1.mp3'], | ||
alias: ['folder2/folder3/1.mp3'], | ||
src: ['folder2/folder3/1.ogg', 'folder2/folder3/1.mp3'], | ||
}, | ||
{ | ||
|
@@ -761,17 +761,15 @@ describe('Manifest', () => | |
assets: [ | ||
{ | ||
alias: [ | ||
'folder/json.json', | ||
'folder/json' | ||
'folder/json.json' | ||
], | ||
src: [ | ||
'folder/json.json' | ||
] | ||
}, | ||
{ | ||
alias: [ | ||
'folder/json.json5', | ||
'folder/json' | ||
'folder/json.json5' | ||
], | ||
src: [ | ||
'folder/json.json5' | ||
|
@@ -811,17 +809,15 @@ describe('Manifest', () => | |
}, | ||
{ | ||
alias: [ | ||
'spine/dragon.json', | ||
'spine/dragon' | ||
'spine/dragon.json' | ||
], | ||
src: [ | ||
'spine/dragon.json' | ||
] | ||
}, | ||
{ | ||
alias: [ | ||
'spine/dragon.atlas', | ||
'spine/dragon' | ||
'spine/dragon.atlas' | ||
], | ||
src: [ | ||
'spine/[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { existsSync, readFileSync } from 'fs-extra'; | ||
import { readFileSync } from 'fs-extra'; | ||
import glob from 'glob-promise'; | ||
import { assetPath, createFolder, getInputDir, getOutputDir } from '../../../shared/test'; | ||
import { spineAtlasCacheBuster } from '../src/spineAtlasCacheBuster'; | ||
import { spineAtlasCompress } from '../src/spineAtlasCompress'; | ||
|
@@ -128,37 +129,62 @@ describe('Spine Atlas All', () => | |
}); | ||
|
||
await assetpack.run(); | ||
const globPath = `${outputDir}/*.{atlas,png,webp}`; | ||
const files = await glob(globPath); | ||
|
||
[ | ||
{ | ||
atlas: `[email protected]`, | ||
png1: `[email protected]`, | ||
png2: `[email protected]` | ||
}, | ||
{ | ||
atlas: `dragon-spj8.webp.atlas`, | ||
png1: `dragon-rSwKOg.webp`, | ||
png2: `dragon2-ws3uhw.webp` | ||
}, | ||
{ | ||
atlas: `[email protected]`, | ||
png1: `[email protected]`, | ||
png2: `[email protected]` | ||
}, | ||
{ | ||
atlas: `dragon-O471eg.png.atlas`, | ||
png1: `dragon-vezElA.png`, | ||
png2: `dragon2-3UnJNw.png` | ||
} | ||
].forEach(({ atlas, png1, png2 }) => | ||
// need two sets of files | ||
expect(files.length).toBe(12); | ||
expect(files.filter((file) => file.endsWith('.atlas')).length).toBe(4); | ||
expect(files.filter((file) => file.endsWith('.png')).length).toBe(4); | ||
expect(files.filter((file) => file.endsWith('.webp')).length).toBe(4); | ||
expect(files.filter((file) => file.endsWith('.jpg')).length).toBe(0); | ||
|
||
const atlasFiles = files.filter((file) => file.endsWith('.atlas')); | ||
const pngFiles = files.filter((file) => file.endsWith('.png')); | ||
const webpFiles = files.filter((file) => file.endsWith('.webp')); | ||
|
||
// check that the files are correct | ||
atlasFiles.forEach((atlasFile) => | ||
{ | ||
const rawAtlas = readFileSync(`${outputDir}/${atlas}`); | ||
const rawAtlas = readFileSync(atlasFile); | ||
const isHalfSize = atlasFile.includes('@0.5x'); | ||
const isWebp = atlasFile.includes('.webp'); | ||
const isPng = atlasFile.includes('.png'); | ||
|
||
const checkFiles = (fileList: string[], isHalfSize: boolean, isFileType: boolean) => | ||
{ | ||
fileList.forEach((file) => | ||
{ | ||
// remove the outputDir | ||
file = file.replace(`${outputDir}/`, ''); | ||
const isFileHalfSize = file.includes('@0.5x'); | ||
const isFileFileType = file.includes(isWebp ? '.webp' : '.png'); | ||
const shouldExist = isHalfSize === isFileHalfSize && isFileType === isFileFileType; | ||
|
||
expect(rawAtlas.includes(png1)).toBeTruthy(); | ||
expect(rawAtlas.includes(png2)).toBeTruthy(); | ||
expect(rawAtlas.includes(file)).toBe(shouldExist); | ||
}); | ||
}; | ||
|
||
expect(existsSync(`${outputDir}/${png1}`)).toBeTruthy(); | ||
expect(existsSync(`${outputDir}/${png2}`)).toBeTruthy(); | ||
if (isHalfSize) | ||
{ | ||
if (isWebp) | ||
{ | ||
checkFiles(webpFiles, true, true); | ||
} | ||
else if (isPng) | ||
{ | ||
checkFiles(pngFiles, true, true); | ||
} | ||
} | ||
else | ||
if (isWebp) | ||
{ | ||
checkFiles(webpFiles, false, true); | ||
} | ||
else if (isPng) | ||
{ | ||
checkFiles(pngFiles, false, true); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters