Skip to content

Commit 617988c

Browse files
committed
add test
1 parent babd642 commit 617988c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

web_src/js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function translateDay(day) {
8787
}
8888

8989
// convert a Blob to a DataURI
90-
function blobToDataURI(blob) {
90+
export function blobToDataURI(blob) {
9191
return new Promise((resolve, reject) => {
9292
try {
9393
const reader = new FileReader();

web_src/js/utils.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {expect, test} from 'vitest';
22
import {
33
basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref,
4-
prettyNumber, parseUrl, translateMonth, translateDay
4+
prettyNumber, parseUrl, translateMonth, translateDay, blobToDataURI,
55
} from './utils.js';
66

77
test('basename', () => {
@@ -131,3 +131,8 @@ test('translateDay', () => {
131131
expect(translateDay(5)).toEqual('pt.');
132132
document.documentElement.lang = originalLang;
133133
});
134+
135+
test('blobToDataURI', async () => {
136+
const blob = new Blob([JSON.stringify({test: true})], {type: 'application/json'});
137+
expect(await blobToDataURI(blob)).toEqual('data:application/json;base64,eyJ0ZXN0Ijp0cnVlfQ==');
138+
});

0 commit comments

Comments
 (0)