mirror of
https://github.com/outline/outline.git
synced 2026-05-21 10:48:54 -05:00
6c9f265918
* feat: Lossless JSON import * transform node only when attachments are present in the zip
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import path from "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);
|
|
});
|
|
});
|