Johann150
38786b6999
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline failed
ci/woodpecker/push/test unknown status
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-sw Pipeline failed
This allows to get rid of the special loader for ts files. There is no need for the test files to be written in TypeScript, plain JavaScript should be fine for this purpose.
30 lines
610 B
JavaScript
30 lines
610 B
JavaScript
import { Resolver } from '../../built/remote/activitypub/resolver.js';
|
|
|
|
export class MockResolver extends Resolver {
|
|
_rs = new Map();
|
|
|
|
async _register(uri, content, type = 'application/activity+json') {
|
|
this._rs.set(uri, {
|
|
type,
|
|
content: typeof content === 'string' ? content : JSON.stringify(content),
|
|
});
|
|
}
|
|
|
|
async resolve(value) {
|
|
if (typeof value !== 'string') return value;
|
|
|
|
const r = this._rs.get(value);
|
|
|
|
if (!r) {
|
|
throw {
|
|
name: 'StatusError',
|
|
statusCode: 404,
|
|
message: 'Not registed for mock',
|
|
};
|
|
}
|
|
|
|
const object = JSON.parse(r.content);
|
|
|
|
return object;
|
|
}
|
|
}
|