Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should passes when used properly', () => {
moveAsync({ from: '', to: '' }).then(fileInfo => {
(fileInfo: void);
// $ExpectError: check any
(fileInfo: number);
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
moveAsync();
// $ExpectError: first argument must be an object
moveAsync(69);
// $ExpectError: need 'to' prop
moveAsync({ from: '' });
// $ExpectError: need 'from' prop
moveAsync({ to: '' });
moveAsync({
// $ExpectError: need string
from: 69,
// $ExpectError: need string
to: 69,
});
});
});
async getPath(): Promise {
const { uri, options } = this;
const { path, exists, tmpPath } = await getCacheEntry(uri);
if (exists) {
return path;
}
const result = await FileSystem.createDownloadResumable(uri, tmpPath, options).downloadAsync();
// If the image download failed, we don't cache anything
if (result && result.status !== 200) {
return undefined;
}
await FileSystem.moveAsync({ from: tmpPath, to: path });
return path;
}
}
async getPath() {
const { uri, options } = this
const { path, exists, tmpPath } = await getCacheEntry(uri)
if (exists) {
return path
}
const result = await FileSystem.createDownloadResumable(
uri,
tmpPath,
options
).downloadAsync()
// If the image download failed, we don't cache anything
if (result && result.status !== 200) {
return undefined
}
await FileSystem.moveAsync({ from: tmpPath, to: path })
return path
}
}