Write download-project tests

This commit is contained in:
Thomas Weber committed 2021-07-07 20:46:37 -05:00
1 parent 15a6197d1f
commit a287c19aba
5 files changed
+40 -1

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import fs from 'fs';
import path from 'path';
import Blob from 'node-blob';
import downloadProject from '../../src/packager/lib/download-project'
global.Blob = Blob;
const emptyProgressCallback = () => {};
const readTestProject = (name) => {
const buffer = fs.readFileSync(path.resolve(__dirname, 'projects', name));
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
};
test('sb3', async () => {
const project = await downloadProject(await readTestProject('no-music.sb3'), emptyProgressCallback);
expect(project.type).toBe('sb3');
expect(project.analysis.stageVariables['`jEk@4|i[#Fk?(8x)AV.-my variable']).toEqual({
name: 'my variable',
isCloud: false
});
expect(project.analysis.stageVariables['BHEUfE_ev.6Eib^2/3nu']).toEqual({
name: '☁ Cloud variable',
isCloud: true
});
expect(project.analysis.usesMusic).toBe(false);
});
test('sb3 with music', async () => {
const project = await downloadProject(await readTestProject('music.sb3'), emptyProgressCallback);
expect(project.analysis.usesMusic).toBe(true);
});
Binary file not shown.
Binary file not shown.