| 
									
										
										
										
											2023-11-01 00:41:35 +01:00
										 |  |  | const { | 
					
						
							|  |  |  |     describeEtapi, postEtapi, | 
					
						
							|  |  |  |     postEtapiContent, | 
					
						
							| 
									
										
										
										
											2023-11-22 19:34:48 +01:00
										 |  |  | } = require('../support/etapi.js'); | 
					
						
							| 
									
										
										
										
											2023-11-01 00:41:35 +01:00
										 |  |  | const fs = require("fs"); | 
					
						
							|  |  |  | const path = require("path"); | 
					
						
							|  |  |  | const {getEtapiContent} = require("../support/etapi.js"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describeEtapi("import", () => { | 
					
						
							|  |  |  |     it("import", async () => { | 
					
						
							|  |  |  |         const zipFileBuffer = fs.readFileSync(path.resolve(__dirname, 'test-export.zip')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const response = await postEtapiContent("notes/root/import", zipFileBuffer); | 
					
						
							|  |  |  |         expect(response.status).toEqual(201); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const {note, branch} = await response.json(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(note.title).toEqual("test-export"); | 
					
						
							|  |  |  |         expect(branch.parentNoteId).toEqual("root"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const content = await (await getEtapiContent(`notes/${note.noteId}/content`)).text(); | 
					
						
							|  |  |  |         expect(content).toContain("test export content"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | }); |