@@ -50,15 +50,14 @@ directory_test(async (t, root) => {
50
50
const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
51
51
const dir_in_dir =
52
52
await dir_src . getDirectoryHandle ( 'dir-in-dir' , { create : true } ) ;
53
- await dir_in_dir . move ( dir_dest , "" ) ;
53
+ await dir_in_dir . move ( dir_dest , '' ) ;
54
+
55
+ await promise_rejects_js ( t , TypeError , dir_in_dir . move ( dir_dest , '' ) ) ;
54
56
55
57
assert_array_equals (
56
- await getSortedDirectoryEntries ( root ) , [ 'dir-dest/' , 'dir-src/' ] ) ;
57
- assert_array_equals ( await getSortedDirectoryEntries ( dir_src ) , [ ] ) ;
58
- assert_array_equals (
59
- await getSortedDirectoryEntries ( dir_dest ) , [ 'dir-in-dir/' ] ) ;
60
- assert_array_equals ( await getSortedDirectoryEntries ( dir_in_dir ) , [ ] ) ;
61
- } , 'move(dir, "") to move an empty directory to a new directory' ) ;
58
+ await getSortedDirectoryEntries ( dir_src ) , [ 'dir-before/' ] ) ;
59
+ assert_array_equals ( await getSortedDirectoryEntries ( dir_dest ) , [ ] ) ;
60
+ } , 'move(dir, "") to move a directory to a new directory fails' ) ;
62
61
63
62
directory_test ( async ( t , root ) => {
64
63
const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
@@ -75,26 +74,6 @@ directory_test(async (t, root) => {
75
74
assert_array_equals ( await getSortedDirectoryEntries ( dir_in_dir ) , [ ] ) ;
76
75
} , 'move(dir, name) to move an empty directory to a new directory' ) ;
77
76
78
- directory_test ( async ( t , root ) => {
79
- const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
80
- const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
81
- const dir_in_dir =
82
- await dir_src . getDirectoryHandle ( 'dir-in-dir' , { create : true } ) ;
83
- const file =
84
- await createFileWithContents ( t , 'file-in-dir' , 'abc' , dir_in_dir ) ;
85
- await dir_in_dir . move ( dir_dest , "" ) ;
86
-
87
- assert_array_equals (
88
- await getSortedDirectoryEntries ( root ) , [ 'dir-dest/' , 'dir-src/' ] ) ;
89
- assert_array_equals ( await getSortedDirectoryEntries ( dir_src ) , [ ] ) ;
90
- assert_array_equals (
91
- await getSortedDirectoryEntries ( dir_dest ) , [ 'dir-in-dir/' ] ) ;
92
- assert_array_equals (
93
- await getSortedDirectoryEntries ( dir_in_dir ) , [ 'file-in-dir' ] ) ;
94
- // `file` should be invalidated after moving directories.
95
- await promise_rejects_dom ( t , 'NotFoundError' , getFileContents ( file ) ) ;
96
- } , 'move(dir, "") to move a non-empty directory to a new directory' ) ;
97
-
98
77
directory_test ( async ( t , root ) => {
99
78
const dir_src = await root . getDirectoryHandle ( 'dir-src' , { create : true } ) ;
100
79
const dir_dest = await root . getDirectoryHandle ( 'dir-dest' , { create : true } ) ;
@@ -142,33 +121,6 @@ directory_test(async (t, root) => {
142
121
assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
143
122
} , 'move(dir) can be called multiple times' ) ;
144
123
145
- directory_test ( async ( t , root ) => {
146
- const dir1 = await root . getDirectoryHandle ( 'dir1' , { create : true } ) ;
147
- const dir2 = await root . getDirectoryHandle ( 'dir2' , { create : true } ) ;
148
- const handle = await createFileWithContents ( t , 'file' , 'foo' , root ) ;
149
-
150
- await handle . move ( dir1 , "" ) ;
151
- assert_array_equals (
152
- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' ] ) ;
153
- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ 'file' ] ) ;
154
- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ ] ) ;
155
- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
156
-
157
- await handle . move ( dir2 , "" ) ;
158
- assert_array_equals (
159
- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' ] ) ;
160
- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ ] ) ;
161
- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ 'file' ] ) ;
162
- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
163
-
164
- await handle . move ( root , "" ) ;
165
- assert_array_equals (
166
- await getSortedDirectoryEntries ( root ) , [ 'dir1/' , 'dir2/' , 'file' ] ) ;
167
- assert_array_equals ( await getSortedDirectoryEntries ( dir1 ) , [ ] ) ;
168
- assert_array_equals ( await getSortedDirectoryEntries ( dir2 ) , [ ] ) ;
169
- assert_equals ( await getFileContents ( handle ) , 'foo' ) ;
170
- } , 'move(dir, "") can be called multiple times' ) ;
171
-
172
124
directory_test ( async ( t , root ) => {
173
125
const dir1 = await root . getDirectoryHandle ( 'dir1' , { create : true } ) ;
174
126
const dir2 = await root . getDirectoryHandle ( 'dir2' , { create : true } ) ;
0 commit comments