@@ -5,8 +5,9 @@ import { getByLabelText, waitFor } from '@testing-library/dom';
55import { cleanup } from '@testing-library/react' ;
66import userEvent from '@testing-library/user-event' ;
77import React from 'react' ;
8- import { testRender } from '../../test' ;
8+ import { testRender , uuid } from '../../test' ;
99import {
10+ FileMetadata ,
1011 fileStorageArchiveAllFiles ,
1112 fileStorageExportFile ,
1213} from '../fileStorage/actions' ;
@@ -19,10 +20,16 @@ afterEach(async () => {
1920 localStorage . clear ( ) ;
2021} ) ;
2122
23+ const testFile : FileMetadata = {
24+ uuid : uuid ( 0 ) ,
25+ path : 'test.file' ,
26+ sha256 : '' ,
27+ } ;
28+
2229describe ( 'archive button' , ( ) => {
2330 it ( 'should be enabled if there are files' , ( ) => {
2431 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
25- fileStorage : { fileNames : [ 'test.file' ] } ,
32+ fileStorage : { files : [ testFile ] } ,
2633 } ) ;
2734
2835 const button = explorer . getByTitle ( 'Backup all files' ) ;
@@ -34,7 +41,7 @@ describe('archive button', () => {
3441
3542 it ( 'should be disabled if there are no files' , ( ) => {
3643 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
37- fileStorage : { fileNames : [ ] } ,
44+ fileStorage : { files : [ ] } ,
3845 } ) ;
3946
4047 const button = explorer . getByTitle ( 'Backup all files' ) ;
@@ -75,7 +82,7 @@ describe('new file button', () => {
7582describe ( 'tree item' , ( ) => {
7683 it ( 'should dispatch action when button is clicked' , async ( ) => {
7784 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
78- fileStorage : { fileNames : [ 'test.file' ] } ,
85+ fileStorage : { files : [ testFile ] } ,
7986 } ) ;
8087
8188 expect (
@@ -93,7 +100,7 @@ describe('tree item', () => {
93100
94101 it ( 'should dispatch action when key is pressed' , async ( ) => {
95102 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
96- fileStorage : { fileNames : [ 'test.file' ] } ,
103+ fileStorage : { files : [ testFile ] } ,
97104 } ) ;
98105
99106 expect (
@@ -110,7 +117,7 @@ describe('tree item', () => {
110117
111118 it ( 'should dispatch delete action when button is clicked' , async ( ) => {
112119 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
113- fileStorage : { fileNames : [ 'test.file' ] } ,
120+ fileStorage : { files : [ testFile ] } ,
114121 } ) ;
115122
116123 // NB: this button is intentionally not accessible (by role) since
@@ -124,7 +131,7 @@ describe('tree item', () => {
124131
125132 it ( 'should dispatch delete action when key is pressed' , async ( ) => {
126133 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
127- fileStorage : { fileNames : [ 'test.file' ] } ,
134+ fileStorage : { files : [ testFile ] } ,
128135 } ) ;
129136
130137 const treeItem = explorer . getByRole ( 'treeitem' , { name : 'test.file' } ) ;
@@ -137,7 +144,7 @@ describe('tree item', () => {
137144
138145 it ( 'should dispatch export action when button is clicked' , async ( ) => {
139146 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
140- fileStorage : { fileNames : [ 'test.file' ] } ,
147+ fileStorage : { files : [ testFile ] } ,
141148 } ) ;
142149
143150 // NB: this button is intentionally not accessible (by role) since
@@ -151,7 +158,7 @@ describe('tree item', () => {
151158
152159 it ( 'should dispatch export action when key is pressed' , async ( ) => {
153160 const [ explorer , dispatch ] = testRender ( < Explorer /> , {
154- fileStorage : { fileNames : [ 'test.file' ] } ,
161+ fileStorage : { files : [ testFile ] } ,
155162 } ) ;
156163
157164 const treeItem = explorer . getByRole ( 'treeitem' , { name : 'test.file' } ) ;
0 commit comments