mirror of
				https://github.com/jely2002/youtube-dl-gui.git
				synced 2021-11-01 22:46:21 +03:00 
			
		
		
		
	chore: fix eslint & tests
This commit is contained in:
		| @@ -11,7 +11,7 @@ class Filepaths { | ||||
|     } | ||||
|  | ||||
|      async generateFilepaths() { | ||||
|         switch (this.detectPlatform()) { | ||||
|         switch (this.platform) { | ||||
|             case "win32": | ||||
|                 this.unpackedPrefix = path.join(path.dirname(this.appPath), "app.asar.unpacked"); | ||||
|                 this.packedPrefix = this.appPath; | ||||
| @@ -22,9 +22,8 @@ class Filepaths { | ||||
|                 this.taskList = this.app.isPackaged ? path.join(this.unpackedPrefix, "taskList") : "taskList"; | ||||
|                 this.ytdlVersion = this.app.isPackaged ? path.join(this.unpackedPrefix, "binaries/ytdlVersion") :"binaries/ytdlVersion"; | ||||
|                 break; | ||||
|             case "win32app": | ||||
|             case "win32app": { | ||||
|                 const appDir = path.basename(path.join(this.appPath, "../../..")).replace(/_(.*)_/g, "_"); | ||||
|                 console.log(appDir) | ||||
|                 this.binaryPath = path.join(this.app.getPath('home'), "AppData/Local/Packages/" + appDir + "/LocalCache/Roaming/open-video-downloader-app"); | ||||
|                 this.persistentPath = path.join(this.app.getPath("appData"), "open-video-downloader-app"); | ||||
|                 this.unpackedPrefix = path.join(path.dirname(this.appPath), "app.asar.unpacked"); | ||||
| @@ -37,6 +36,7 @@ class Filepaths { | ||||
|                 this.taskList = path.join(this.binaryPath, "taskList"); | ||||
|                 this.ytdlVersion = path.join(this.binaryPath, "ytdlVersion"); | ||||
|                 break; | ||||
|             } | ||||
|             case "win32portable": | ||||
|                 this.persistentPath = path.join(this.app.getPath('appData'), "youtube-dl-gui-portable"); | ||||
|                 this.unpackedPrefix = path.join(path.dirname(this.appPath), "app.asar.unpacked"); | ||||
|   | ||||
| @@ -23,7 +23,6 @@ class Video { | ||||
|     } | ||||
|  | ||||
|     setFilename(liveData) { | ||||
|         console.log(liveData) | ||||
|         if(liveData.includes("[download] Destination: ")) { | ||||
|             this.filename = path.basename(liveData.replace("[download] Destination: ", "")); | ||||
|         } else if(liveData.includes("[ffmpeg] Merging formats into \"")) { | ||||
|   | ||||
| @@ -55,7 +55,7 @@ describe('generate filepaths', () => { | ||||
|             instance.createHomeFolder = jest.fn().mockResolvedValue(undefined); | ||||
|             const joinSpy = jest.spyOn(path, 'join').mockReturnValue("path"); | ||||
|             await instance.generateFilepaths(); | ||||
|             if(platform === "linux") expect(joinSpy).toBeCalledTimes(1); | ||||
|             if(platform === "linux" || platform === "win32") expect(joinSpy).toBeCalledTimes(1); | ||||
|             else expect(joinSpy).not.toBeCalled(); | ||||
|             joinSpy.mockRestore(); | ||||
|         } | ||||
| @@ -68,12 +68,12 @@ describe('generate filepaths', () => { | ||||
|        await instance.generateFilepaths(); | ||||
|        expect(instance.createHomeFolder).toBeCalledTimes(1); | ||||
|    }); | ||||
|    it('calls create portable folder when this version is used', async () => { | ||||
|    it('calls create appdata folder when this version is used', async () => { | ||||
|        const instance = instanceBuilder(true, true); | ||||
|        instance.platform = "win32"; | ||||
|        instance.createPortableFolder = jest.fn().mockResolvedValue(undefined); | ||||
|        instance.platform = "win32portable"; | ||||
|        instance.createAppDataFolder = jest.fn().mockResolvedValue(undefined); | ||||
|        await instance.generateFilepaths(); | ||||
|        expect(instance.createPortableFolder).toBeCalledTimes(1); | ||||
|        expect(instance.createAppDataFolder).toBeCalledTimes(1); | ||||
|    }) | ||||
|    it('sets permissions on darwin and linux', async () => { | ||||
|        const platforms = ["win32", "linux", "darwin"]; | ||||
| @@ -113,16 +113,16 @@ describe('create portable folder', () => { | ||||
|         const instance = instanceBuilder(true); | ||||
|         fs.copyFileSync = jest.fn(); | ||||
|         mkdirp.mockResolvedValue(null); | ||||
|         await instance.createPortableFolder(); | ||||
|         await instance.createAppDataFolder(); | ||||
|         expect(fs.copyFileSync).not.toBeCalled(); | ||||
|     }); | ||||
|     it('copies 3 files if the directory did not exist yet', async () => { | ||||
|     it('copies 4 files if the directory did not exist yet', async () => { | ||||
|         const instance = instanceBuilder(true); | ||||
|         fs.copyFileSync = jest.fn(); | ||||
|         const joinSpy = jest.spyOn(path, 'join').mockReturnValue("path"); | ||||
|         mkdirp.mockResolvedValue("path/to/made/directory"); | ||||
|         await instance.createPortableFolder(); | ||||
|         expect(fs.copyFileSync).toBeCalledTimes(3); | ||||
|         await instance.createAppDataFolder() | ||||
|         expect(fs.copyFileSync).toBeCalledTimes(4); | ||||
|         joinSpy.mockRestore(); | ||||
|     }); | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jelle Glebbeek
					Jelle Glebbeek