@@ -95,6 +95,35 @@ describe('Test create method.', () => {
95
95
} ) ;
96
96
} ) ;
97
97
98
+ describe ( 'Test size operations.' , ( ) => {
99
+ it ( 'Creates new files.' , ( ) => {
100
+ const microbitFs = new MicropythonFsHex ( uPyHexFile ) ;
101
+
102
+ expect ( microbitFs . getStorageUsed ( ) ) . toEqual ( 0 ) ;
103
+ expect ( microbitFs . getStorageRemaining ( ) ) . toEqual ( 27648 ) ;
104
+
105
+ microbitFs . create ( 'chunk1.py' , 'first 128 byte chunk' ) ;
106
+
107
+ expect ( microbitFs . getStorageUsed ( ) ) . toEqual ( 128 ) ;
108
+ expect ( microbitFs . getStorageRemaining ( ) ) . toEqual ( 27648 - 128 ) ;
109
+
110
+ microbitFs . create ( 'chunk2.py' , 'second 128 byte chunk' ) ;
111
+
112
+ expect ( microbitFs . getStorageUsed ( ) ) . toEqual ( 256 ) ;
113
+ expect ( microbitFs . getStorageRemaining ( ) ) . toEqual ( 27648 - 256 ) ;
114
+
115
+ microbitFs . create ( 'chunk3.py' , new Uint8Array ( 26800 ) . fill ( 0x60 ) ) ;
116
+
117
+ expect ( microbitFs . getStorageUsed ( ) ) . toEqual ( 27648 - 128 ) ;
118
+ expect ( microbitFs . getStorageRemaining ( ) ) . toEqual ( 128 ) ;
119
+
120
+ microbitFs . create ( 'chunk4.py' , 'fourth chunk' ) ;
121
+
122
+ expect ( microbitFs . getStorageUsed ( ) ) . toEqual ( 27648 ) ;
123
+ expect ( microbitFs . getStorageRemaining ( ) ) . toEqual ( 0 ) ;
124
+ } ) ;
125
+ } ) ;
126
+
98
127
describe ( 'Test write method.' , ( ) => {
99
128
it ( 'Throw error with invalid file name.' , ( ) => {
100
129
const micropythonFs = new MicropythonFsHex ( uPyHexFile ) ;
@@ -504,7 +533,7 @@ describe('Test MicroPython hex filesystem size.', () => {
504
533
it ( 'Get how much available fs space there is in a MicroPython hex file.' , ( ) => {
505
534
const micropythonFs = new MicropythonFsHex ( uPyHexFile ) ;
506
535
507
- const totalSize = micropythonFs . getFsSize ( ) ;
536
+ const totalSize = micropythonFs . getStorageSize ( ) ;
508
537
509
538
// Calculated by hand from the uPyHexFile v1.0.1 release.
510
539
expect ( totalSize ) . toEqual ( 27 * 1024 ) ;
0 commit comments