Skip to content

Commit d3e1fff

Browse files
author
Benjamin Pasero
committed
files - more tests
1 parent e7713c9 commit d3e1fff

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/vs/workbench/services/textfile/test/textFileService.io.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ suite('Files - TextFileService i/o', () => {
570570
assert.equal(result.encoding, 'utf16be');
571571
});
572572

573+
test('readStream - autoguessEncoding', async () => {
574+
const resource = URI.file(join(testDir, 'some_cp1252.txt'));
575+
576+
const result = await service.readStream(resource, { autoGuessEncoding: true });
577+
assert.equal(result.encoding, 'windows1252');
578+
});
579+
573580
test('readStream - FILE_IS_BINARY', async () => {
574581
const resource = URI.file(join(testDir, 'binary.txt'));
575582

@@ -586,4 +593,21 @@ suite('Files - TextFileService i/o', () => {
586593
const result = await service.readStream(URI.file(join(testDir, 'small.txt')), { acceptTextOnly: true });
587594
assert.equal(result.name, 'small.txt');
588595
});
596+
597+
test('read - FILE_IS_BINARY', async () => {
598+
const resource = URI.file(join(testDir, 'binary.txt'));
599+
600+
let error: TextFileOperationError | undefined = undefined;
601+
try {
602+
await service.read(resource, { acceptTextOnly: true });
603+
} catch (err) {
604+
error = err;
605+
}
606+
607+
assert.ok(error);
608+
assert.equal(error!.textFileOperationResult, TextFileOperationResult.FILE_IS_BINARY);
609+
610+
const result = await service.read(URI.file(join(testDir, 'small.txt')), { acceptTextOnly: true });
611+
assert.equal(result.name, 'small.txt');
612+
});
589613
});

0 commit comments

Comments
 (0)