mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
00fb4d1af7
- crypto → node:crypto - fs → node:fs - fs/promises → node:fs/promises - path → node:path - http → node:http - https → node:https - stream → node:stream - buffer → node:buffer - url → node:url - os → node:os - net → node:net - dns → node:dns - events → node:events - readline → node:readline - querystring → node:querystring - util → node:util
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import path from "node:path";
|
|
import { FileOperation } from "@server/models";
|
|
import { buildFileOperation } from "@server/test/factories";
|
|
import ImportJSONTask from "./ImportJSONTask";
|
|
|
|
describe("ImportJSONTask", () => {
|
|
it("should import the documents, attachments", async () => {
|
|
const fileOperation = await buildFileOperation();
|
|
Object.defineProperty(fileOperation, "handle", {
|
|
get() {
|
|
return {
|
|
path: path.resolve(
|
|
__dirname,
|
|
"..",
|
|
"..",
|
|
"test",
|
|
"fixtures",
|
|
"outline-json.zip"
|
|
),
|
|
cleanup: async () => {},
|
|
};
|
|
},
|
|
});
|
|
jest.spyOn(FileOperation, "findByPk").mockResolvedValue(fileOperation);
|
|
|
|
const props = {
|
|
fileOperationId: fileOperation.id,
|
|
};
|
|
|
|
const task = new ImportJSONTask();
|
|
const response = await task.perform(props);
|
|
|
|
expect(response.collections.size).toEqual(1);
|
|
expect(response.documents.size).toEqual(2);
|
|
expect(response.attachments.size).toEqual(1);
|
|
});
|
|
});
|