test(log): cleaunp TextDecoder use (#5407)

tests(log): cleaunp `TextDecoder` use
This commit is contained in:
Asher Gomez 2024-07-11 17:53:06 +10:00 committed by GitHub
parent a32c05fe26
commit 10bcb95c9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 17 deletions

View File

@ -12,9 +12,7 @@ Deno.test({
class TestFileHandler extends FileHandler {
override flush() {
super.flush();
const decoder = new TextDecoder("utf-8");
const data = Deno.readFileSync(LOG_FILE);
const text = decoder.decode(data);
const text = Deno.readTextFileSync(LOG_FILE);
assertEquals(text.slice(-1), "\n");
}

View File

@ -204,20 +204,10 @@ Deno.test({
); // 'ERROR AAA\n' = 10 bytes
fileHandler.destroy();
const decoder = new TextDecoder();
assertEquals(decoder.decode(Deno.readFileSync(LOG_FILE)), "ERROR AAA\n");
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".1")),
"original log file",
);
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".2")),
"original log.1 file",
);
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".3")),
"original log.2 file",
);
assertEquals(Deno.readTextFileSync(LOG_FILE), "ERROR AAA\n");
assertEquals(Deno.readTextFileSync(LOG_FILE + ".1"), "original log file");
assertEquals(Deno.readTextFileSync(LOG_FILE + ".2"), "original log.1 file");
assertEquals(Deno.readTextFileSync(LOG_FILE + ".3"), "original log.2 file");
assert(!existsSync(LOG_FILE + ".4"));
Deno.removeSync(LOG_FILE);