mirror of
https://github.com/smogon/sprites.git
synced 2026-07-18 16:31:33 -05:00
Use mocha for testing
This commit is contained in:
parent
3f60f61e00
commit
f6172a3012
3374
pnpm-lock.yaml
3374
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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'},
|
||||
]));
|
||||
});
|
||||
|
||||
|
Before Width: | Height: | Size: 424 B After Width: | Height: | Size: 424 B |
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 246 B |
|
|
@ -2,6 +2,7 @@
|
|||
"extends": "../../tsconfig-base",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"allowJs": true
|
||||
}
|
||||
"allowJs": true,
|
||||
},
|
||||
"exclude": ["test", "dist", "node_modules"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user