1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-02 06:15:54 +02:00

fix frontend tests broken with aiscript 1.0.0 (#16377)

* test: update test for aiscript 1.0: line info in error

* test: update test for aiscript 1.0: keyword in object literal
This commit is contained in:
anatawa12
2025-08-09 14:12:17 +09:00
committed by GitHub
parent 785b85ee46
commit 103d5a4b44
2 changed files with 24 additions and 8 deletions

View File

@@ -37,6 +37,17 @@ let $iMock = vi.hoisted<Partial<typeof import('@/i.js').$i> | null >(
() => null
);
function errorWithPos<T extends errors.AiScriptError>(
error: T,
line: number,
column: number,
): T {
const pos = { line, column };
error.pos = pos;
error.message = error.message + `\n at <root> (Line ${pos.line}, Column ${pos.column})`;
return error;
}
vi.mock('@/i.js', () => {
return {
get $i() {
@@ -316,7 +327,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:api('https://example.com/api/ping', {})
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('invalid endpoint'),
errorWithPos(new errors.AiScriptRuntimeError('invalid endpoint'), 2, 11),
);
expect(misskeyApiMock).not.toHaveBeenCalled();
});
@@ -325,7 +336,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:api('ping')
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('expected param'),
errorWithPos(new errors.AiScriptRuntimeError('expected param'), 2, 11),
);
expect(misskeyApiMock).not.toHaveBeenCalled();
});
@@ -353,7 +364,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:save('key')
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('Expect anything, but got nothing.'),
errorWithPos(new errors.AiScriptRuntimeError('Expect anything, but got nothing.'), 2, 12),
);
});