Use mocha for testing

This commit is contained in:
Christopher Monsanto 2020-08-22 03:00:00 -04:00
parent 3f60f61e00
commit f6172a3012
6 changed files with 515 additions and 2901 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,13 +6,13 @@
"debug": "^4.1.1"
},
"devDependencies": {
"@types/jest": "^26.0.9",
"jest": "^26.2.2",
"ts-jest": "^26.1.4",
"expect": "^26.4.1",
"mocha": "^8.1.1",
"typescript": "^3.9.7"
},
"scripts": {
"prepare": "tsc"
"prepare": "tsc",
"test": "tsc && mocha dist/test"
},
"type": "module",
"main": "dist/index.js"

View File

@ -1,8 +1,13 @@
import * as pathlib from './path.js';
import * as script from './script.js';
import * as script from '../dist/script.js';
import expect from 'expect';
import path from 'path';
import {fileURLToPath} from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
test('aq', () => {
const spriteSrc = path.join(__dirname, "src");
it('aq', () => {
const aq = new script.ActionQueue();
aq.copy("foo", "bar");
aq.copy("baz", "./bar");
@ -16,29 +21,29 @@ test('aq', () => {
});
test('runOnFile', () => {
it('runOnFile', () => {
const scr = new script.Script('({name: "25"})', 'expr');
const dst = script.runOnFile(scr, '/foo/bar/pikachu.png');
expect(dst).toEqual('25.png');
});
test('run identity', () => {
it('run identity', () => {
const aq = new script.ActionQueue();
const scr = new script.Script(` list(".").forEach(p => copy(p, p))`, 'expr');
script.run(scr, "testsrc", aq);
script.run(scr, spriteSrc, aq);
expect(aq.log).toEqual(expect.arrayContaining([
{type: 'Copy', src: 'testsrc/32.png', dst: "32.png", valid: 'Success'},
{type: 'Copy', src: 'testsrc/192-g-vsmogon.png', dst: "192-g-vsmogon.png", valid: 'Success'},
{type: 'Copy', src: path.join(spriteSrc, '32.png'), dst: "32.png", valid: 'Success'},
{type: 'Copy', src: path.join(spriteSrc, '192-g-vsmogon.png'), dst: "192-g-vsmogon.png", valid: 'Success'},
]));
});
test('run delta', () => {
it('run delta', () => {
const aq = new script.ActionQueue();
const scr = new script.Script(` list(".").forEach(p => copy(p, {dir: "dest"}))`, 'expr');
script.run(scr, "testsrc", aq);
script.run(scr, spriteSrc, aq);
expect(aq.log).toEqual(expect.arrayContaining([
{type: 'Copy', src: 'testsrc/32.png', dst: "dest/32.png", valid: 'Success'},
{type: 'Copy', src: 'testsrc/192-g-vsmogon.png', dst: "dest/192-g-vsmogon.png", valid: 'Success'},
{type: 'Copy', src: path.join(spriteSrc, '32.png'), dst: "dest/32.png", valid: 'Success'},
{type: 'Copy', src: path.join(spriteSrc, '192-g-vsmogon.png'), dst: "dest/192-g-vsmogon.png", valid: 'Success'},
]));
});

View File

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 424 B

View File

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 246 B

View File

@ -2,6 +2,7 @@
"extends": "../../tsconfig-base",
"compilerOptions": {
"outDir": "dist",
"allowJs": true
}
"allowJs": true,
},
"exclude": ["test", "dist", "node_modules"]
}