mirror of
https://github.com/foliojs/pdfkit.git
synced 2026-02-01 16:56:57 +00:00
parent
fd4f285dc4
commit
812a6db941
@ -16,7 +16,7 @@ class VirtualFileSystem {
|
||||
|
||||
if (encoding) {
|
||||
// return a string
|
||||
return typeof data === 'string' ? data : data.toString();
|
||||
return typeof data === 'string' ? data : data.toString(encoding);
|
||||
}
|
||||
|
||||
return new Buffer(data, typeof data === 'string' ? 'base64' : undefined);
|
||||
|
||||
@ -13,6 +13,17 @@ describe('virtual-fs', function() {
|
||||
fs.fileData = {};
|
||||
});
|
||||
|
||||
test('readFileSync', function () {
|
||||
checkMissingFiles(['encoded', 'raw', 'binary']);
|
||||
|
||||
fs.bindFileData({
|
||||
'files/binary': Buffer.from('Buffer content'),
|
||||
});
|
||||
|
||||
const base64Data = fs.readFileSync('files/binary', 'base64');
|
||||
expect(base64Data).toEqual('QnVmZmVyIGNvbnRlbnQ=');
|
||||
});
|
||||
|
||||
test('writeFileSync', function() {
|
||||
checkMissingFiles(['encoded', 'raw', 'binary']);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user