@@ -15,7 +15,6 @@ import {
15
15
ExportSpdxDocumentJsonArgs ,
16
16
ExportSpdxDocumentYamlArgs ,
17
17
ExportType ,
18
- FilePathValidity ,
19
18
} from '../../../shared/shared-types' ;
20
19
import { writeFile } from '../../../shared/write-file' ;
21
20
import { faker } from '../../../testing/Faker' ;
@@ -36,7 +35,6 @@ import {
36
35
getImportFileListener ,
37
36
getImportFileSelectInputListener ,
38
37
getImportFileSelectSaveLocationListener ,
39
- getImportFileValidatePathsListener ,
40
38
getOpenLinkListener ,
41
39
getSelectBaseURLListener ,
42
40
linkHasHttpSchema ,
@@ -526,132 +524,6 @@ describe('getImportFileSelectSaveLocationListener', () => {
526
524
} ) ;
527
525
} ) ;
528
526
529
- describe ( 'getImportFileValidatePathsListener' , ( ) => {
530
- it ( 'recognizes empty strings' , async ( ) => {
531
- const mainWindow = await initWindowAndBackendState ( ) ;
532
-
533
- const inputFilePath = '' ;
534
- const extensions = [ 'json' , 'json.gz' ] ;
535
- const opossumFilePath = ' \t' ;
536
-
537
- const listener = getImportFileValidatePathsListener ( mainWindow ) ;
538
-
539
- jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( true ) ;
540
-
541
- const result = await listener (
542
- { } as Electron . IpcMainInvokeEvent ,
543
- inputFilePath ,
544
- extensions ,
545
- opossumFilePath ,
546
- ) ;
547
-
548
- expect ( result ) . toStrictEqual ( [
549
- FilePathValidity . EMPTY_STRING ,
550
- FilePathValidity . EMPTY_STRING ,
551
- ] ) ;
552
- } ) ;
553
-
554
- it ( 'recognizes non-existent file paths' , async ( ) => {
555
- const mainWindow = await initWindowAndBackendState ( ) ;
556
-
557
- const inputFilePath = '/home/input.json' ;
558
- const extensions = [ 'json' , 'json.gz' ] ;
559
- const opossumFilePath = '/hom/input.opossum' ;
560
-
561
- const listener = getImportFileValidatePathsListener ( mainWindow ) ;
562
-
563
- jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( false ) ;
564
-
565
- const result = await listener (
566
- { } as Electron . IpcMainInvokeEvent ,
567
- inputFilePath ,
568
- extensions ,
569
- opossumFilePath ,
570
- ) ;
571
-
572
- expect ( result ) . toStrictEqual ( [
573
- FilePathValidity . PATH_DOESNT_EXIST ,
574
- FilePathValidity . PATH_DOESNT_EXIST ,
575
- ] ) ;
576
- } ) ;
577
-
578
- it ( 'recognizes invalid file extensions' , async ( ) => {
579
- const mainWindow = await initWindowAndBackendState ( ) ;
580
-
581
- const inputFilePath = '/home/input.txt' ;
582
- const extensions = [ 'json' , 'json.gz' ] ;
583
- const opossumFilePath = '/home/input.oposs' ;
584
-
585
- const listener = getImportFileValidatePathsListener ( mainWindow ) ;
586
-
587
- jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( true ) ;
588
-
589
- const result = await listener (
590
- { } as Electron . IpcMainInvokeEvent ,
591
- inputFilePath ,
592
- extensions ,
593
- opossumFilePath ,
594
- ) ;
595
-
596
- expect ( result ) . toStrictEqual ( [
597
- FilePathValidity . WRONG_EXTENSION ,
598
- FilePathValidity . WRONG_EXTENSION ,
599
- ] ) ;
600
- } ) ;
601
-
602
- it ( 'returns valid when no problem is found' , async ( ) => {
603
- const mainWindow = await initWindowAndBackendState ( ) ;
604
-
605
- const inputFilePath = '/home/input.json.gz' ;
606
- const extensions = [ 'json' , 'json.gz' ] ;
607
- const opossumFilePath = '/home/input.opossum' ;
608
-
609
- const listener = getImportFileValidatePathsListener ( mainWindow ) ;
610
-
611
- jest
612
- . spyOn ( fs , 'existsSync' )
613
- . mockReturnValueOnce ( true )
614
- . mockReturnValueOnce ( true )
615
- . mockReturnValueOnce ( false ) ;
616
-
617
- const result = await listener (
618
- { } as Electron . IpcMainInvokeEvent ,
619
- inputFilePath ,
620
- extensions ,
621
- opossumFilePath ,
622
- ) ;
623
-
624
- expect ( result ) . toStrictEqual ( [
625
- FilePathValidity . VALID ,
626
- FilePathValidity . VALID ,
627
- ] ) ;
628
- } ) ;
629
-
630
- it ( 'gives overwrite warning when opossum file already exists' , async ( ) => {
631
- const mainWindow = await initWindowAndBackendState ( ) ;
632
-
633
- const inputFilePath = '/home/input.json.gz' ;
634
- const extensions = [ 'json' , 'json.gz' ] ;
635
- const opossumFilePath = '/home/input.opossum' ;
636
-
637
- const listener = getImportFileValidatePathsListener ( mainWindow ) ;
638
-
639
- jest . spyOn ( fs , 'existsSync' ) . mockReturnValue ( true ) ;
640
-
641
- const result = await listener (
642
- { } as Electron . IpcMainInvokeEvent ,
643
- inputFilePath ,
644
- extensions ,
645
- opossumFilePath ,
646
- ) ;
647
-
648
- expect ( result ) . toStrictEqual ( [
649
- FilePathValidity . VALID ,
650
- FilePathValidity . OVERWRITE_WARNING ,
651
- ] ) ;
652
- } ) ;
653
- } ) ;
654
-
655
527
function initWindowAndBackendState ( ) : Promise < BrowserWindow > {
656
528
( writeCsvToFile as jest . Mock ) . mockReset ( ) ;
657
529
setGlobalBackendState ( { } ) ;
0 commit comments