mirror of
https://github.com/morris/vanilla-todo.git
synced 2025-08-22 05:33:06 +02:00
add data import/export (#11)
This commit is contained in:
@@ -6,3 +6,22 @@ test('formatDate', () => {
|
||||
expect(formatDate(new Date(0))).toEqual('January 1st 1970');
|
||||
expect(formatDate(new Date('2023-05-13 12:00:00'))).toEqual('May 13th 2023');
|
||||
});
|
||||
|
||||
test('toDataURL', async ({ page }) => {
|
||||
// Needs to be tested in the browser because FileReader is not available in Node.js
|
||||
// However, this approach does not support test coverage :'(
|
||||
await page.goto('http://localhost:8080');
|
||||
|
||||
const dataURL = await page.evaluate(async () => {
|
||||
const { toDataURL } = await import('./scripts/util.js');
|
||||
const text = 'a Ā 𐀀 文 🦄';
|
||||
const json = JSON.stringify({ text });
|
||||
const dataURL = await toDataURL(json, 'application/json;charset=utf-8');
|
||||
|
||||
return dataURL;
|
||||
});
|
||||
|
||||
expect(dataURL).toEqual(
|
||||
'data:application/json;charset=utf-8;base64,eyJ0ZXh0IjoiYSDEgCDwkICAIOaWhyDwn6aEIn0=',
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user