summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.test.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-11-21 10:59:42 +0100
committerGitHub <noreply@github.com>2022-11-21 17:59:42 +0800
commitc2fb27beb4a0f9a9ad1478937439bcf4c43aff4a (patch)
tree0f690c4aeecb6caa0a8cb24623141f3e569b8e72 /web_src/js/utils.test.js
parente4eaa68a2b2355c7333406fdcbb8b118677b95df (diff)
downloadgitea-c2fb27beb4a0f9a9ad1478937439bcf4c43aff4a.tar.gz
gitea-c2fb27beb4a0f9a9ad1478937439bcf4c43aff4a.zip
Improvements for Content Copy (#21842)
It now supports copying Markdown, SVG and Images (not in Firefox currently because of lacking [`ClipboardItem`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem) support, but can be enabled in `about:config` and works). It will fetch the data if in a rendered view or when it's an image. Followup to https://github.com/go-gitea/gitea/pull/21629.
Diffstat (limited to 'web_src/js/utils.test.js')
-rw-r--r--web_src/js/utils.test.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js
index 0567a5c64a..1df0caa211 100644
--- a/web_src/js/utils.test.js
+++ b/web_src/js/utils.test.js
@@ -1,7 +1,7 @@
import {expect, test} from 'vitest';
import {
basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref,
- prettyNumber, parseUrl, translateMonth, translateDay
+ prettyNumber, parseUrl, translateMonth, translateDay, blobToDataURI,
} from './utils.js';
test('basename', () => {
@@ -131,3 +131,8 @@ test('translateDay', () => {
expect(translateDay(5)).toEqual('pt.');
document.documentElement.lang = originalLang;
});
+
+test('blobToDataURI', async () => {
+ const blob = new Blob([JSON.stringify({test: true})], {type: 'application/json'});
+ expect(await blobToDataURI(blob)).toEqual('data:application/json;base64,eyJ0ZXN0Ijp0cnVlfQ==');
+});