summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2023-09-26 13:06:02 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2023-09-26 13:06:02 +0200
commit13a2d694f4314a9ae24d614c75b18a7be514eedd (patch)
treefb7dcc5638f9ef1cf0fb1776941f4dfa3aa2541a /apps/files
parent2ebd5bb939a2e57b569bc6713290af67a3d91689 (diff)
downloadnextcloud-server-13a2d694f4314a9ae24d614c75b18a7be514eedd.tar.gz
nextcloud-server-13a2d694f4314a9ae24d614c75b18a7be514eedd.zip
fix(files): Adjust files list jsunit tests for file size bugfix
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/tests/js/fileUploadSpec.js2
-rw-r--r--apps/files/tests/js/filelistSpec.js6
-rw-r--r--apps/files/tests/js/filesummarySpec.js42
-rw-r--r--apps/files/tests/js/mainfileinfodetailviewSpec.js2
4 files changed, 26 insertions, 26 deletions
diff --git a/apps/files/tests/js/fileUploadSpec.js b/apps/files/tests/js/fileUploadSpec.js
index e15514b39e2..fa7ee1f5d07 100644
--- a/apps/files/tests/js/fileUploadSpec.js
+++ b/apps/files/tests/js/fileUploadSpec.js
@@ -113,7 +113,7 @@ describe('OC.Upload tests', function() {
});
it('does not add file if it exceeds free space', function(done) {
var result;
- $('#free_space').val(1000);
+ $('#free_space').val(1024);
failStub.callsFake(function(){
expect(failStub.calledOnce).toEqual(true);
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index b7f9fb2ff39..3d80591fd14 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -539,7 +539,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.fileinfo').text()).toEqual('2 files');
expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
- expect($summary.find('.filesize').text()).toEqual('70 KB');
+ expect($summary.find('.filesize').text()).toEqual('69 KB');
expect(fileList.isEmpty).toEqual(false);
});
it('Shows empty content when removing last file', function() {
@@ -609,7 +609,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.fileinfo').text()).toEqual('1 file');
expect($summary.find('.dirinfo').hasClass('hidden')).toEqual(false);
expect($summary.find('.fileinfo').hasClass('hidden')).toEqual(false);
- expect($summary.find('.filesize').text()).toEqual('58 KB');
+ expect($summary.find('.filesize').text()).toEqual('57 KB');
expect(fileList.isEmpty).toEqual(false);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
@@ -1138,7 +1138,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.hasClass('hidden')).toEqual(false);
expect($summary.find('.dirinfo').text()).toEqual('1 folder');
expect($summary.find('.fileinfo').text()).toEqual('3 files');
- expect($summary.find('.filesize').text()).toEqual('70 KB');
+ expect($summary.find('.filesize').text()).toEqual('69 KB');
});
it('shows headers, summary and hide empty content message after setting files', function(){
fileList.setFiles(testFiles);
diff --git a/apps/files/tests/js/filesummarySpec.js b/apps/files/tests/js/filesummarySpec.js
index 22c95abd307..03f39304a89 100644
--- a/apps/files/tests/js/filesummarySpec.js
+++ b/apps/files/tests/js/filesummarySpec.js
@@ -39,7 +39,7 @@ describe('OCA.Files.FileSummary tests', function() {
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000
+ totalSize: 256*1024,
});
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('5 folders');
@@ -60,9 +60,9 @@ describe('OCA.Files.FileSummary tests', function() {
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000
+ totalSize: 256*1024
});
- s.add({type: 'file', size: 256000});
+ s.add({type: 'file', size: 256*1024});
s.add({type: 'dir', size: 100});
s.update();
expect($container.hasClass('hidden')).toEqual(false);
@@ -71,16 +71,16 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.filesize').text()).toEqual('512 KB');
expect(s.summary.totalDirs).toEqual(6);
expect(s.summary.totalFiles).toEqual(3);
- expect(s.summary.totalSize).toEqual(512100);
+ expect(s.summary.totalSize).toEqual(512*1024 + 100);
});
it('decreases summary when removing files', function() {
var s = new FileSummary($container);
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000
+ totalSize: 256*1024
});
- s.remove({type: 'file', size: 128000});
+ s.remove({type: 'file', size: 128*1024});
s.remove({type: 'dir', size: 100});
s.update();
expect($container.hasClass('hidden')).toEqual(false);
@@ -89,7 +89,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.filesize').text()).toEqual('128 KB');
expect(s.summary.totalDirs).toEqual(4);
expect(s.summary.totalFiles).toEqual(1);
- expect(s.summary.totalSize).toEqual(127900);
+ expect(s.summary.totalSize).toEqual(128*1024 - 100);
});
it('renders filtered summary as text', function() {
@@ -97,7 +97,7 @@ describe('OCA.Files.FileSummary tests', function() {
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000,
+ totalSize: 256*1024,
filter: 'foo'
});
expect($container.hasClass('hidden')).toEqual(false);
@@ -121,11 +121,11 @@ describe('OCA.Files.FileSummary tests', function() {
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000,
+ totalSize: 256*1024,
filter: 'foo'
});
- s.add({name: 'bar.txt', type: 'file', size: 256000});
- s.add({name: 'foo.txt', type: 'file', size: 256001});
+ s.add({name: 'bar.txt', type: 'file', size: 256*1024});
+ s.add({name: 'foo.txt', type: 'file', size: 256*1024 + 1});
s.add({name: 'bar', type: 'dir', size: 100});
s.add({name: 'foo', type: 'dir', size: 102});
s.update();
@@ -136,18 +136,18 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.filesize').text()).toEqual('512 KB');
expect(s.summary.totalDirs).toEqual(6);
expect(s.summary.totalFiles).toEqual(3);
- expect(s.summary.totalSize).toEqual(512103);
+ expect(s.summary.totalSize).toEqual(512*1024 + 1 + 102);
});
it('decreases filtered summary when removing files', function() {
var s = new FileSummary($container);
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000,
+ totalSize: 256*1024,
filter: 'foo'
});
- s.remove({name: 'bar.txt', type: 'file', size: 128000});
- s.remove({name: 'foo.txt', type: 'file', size: 127999});
+ s.remove({name: 'bar.txt', type: 'file', size: 128*1024});
+ s.remove({name: 'foo.txt', type: 'file', size: 128*1024 - 1});
s.remove({name: 'bar', type: 'dir', size: 100});
s.remove({name: 'foo', type: 'dir', size: 98});
s.update();
@@ -158,7 +158,7 @@ describe('OCA.Files.FileSummary tests', function() {
expect($container.find('.filesize').text()).toEqual('128 KB');
expect(s.summary.totalDirs).toEqual(4);
expect(s.summary.totalFiles).toEqual(1);
- expect(s.summary.totalSize).toEqual(127903);
+ expect(s.summary.totalSize).toEqual(256*1024 - (128*1024 - 1) - 98);
});
it('properly sum up pending folder sizes after adding', function() {
var s = new FileSummary($container);
@@ -206,9 +206,9 @@ describe('OCA.Files.FileSummary tests', function() {
it('renders hidden count section when hidden files are hidden', function() {
window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false });
- summary.add({name: 'abc', type: 'file', size: 256000});
+ summary.add({name: 'abc', type: 'file', size: 256*1024});
summary.add({name: 'def', type: 'dir', size: 100});
- summary.add({name: '.hidden', type: 'dir', size: 512000});
+ summary.add({name: '.hidden', type: 'dir', size: 512*1024});
summary.update();
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('2 folders');
@@ -220,9 +220,9 @@ describe('OCA.Files.FileSummary tests', function() {
it('does not render hidden count section when hidden files exist but are visible', function() {
window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: true });
- summary.add({name: 'abc', type: 'file', size: 256000});
+ summary.add({name: 'abc', type: 'file', size: 256*1024});
summary.add({name: 'def', type: 'dir', size: 100});
- summary.add({name: '.hidden', type: 'dir', size: 512000});
+ summary.add({name: '.hidden', type: 'dir', size: 512*1024});
summary.update();
expect($container.hasClass('hidden')).toEqual(false);
expect($container.find('.dirinfo').text()).toEqual('2 folders');
@@ -233,7 +233,7 @@ describe('OCA.Files.FileSummary tests', function() {
it('does not render hidden count section when no hidden files exist', function() {
window._nc_event_bus.emit('files:config:updated', { key: 'show_hidden', value: false });
- summary.add({name: 'abc', type: 'file', size: 256000});
+ summary.add({name: 'abc', type: 'file', size: 256*1024});
summary.add({name: 'def', type: 'dir', size: 100});
summary.update();
expect($container.hasClass('hidden')).toEqual(false);
diff --git a/apps/files/tests/js/mainfileinfodetailviewSpec.js b/apps/files/tests/js/mainfileinfodetailviewSpec.js
index b63c36199a6..5793db8fb98 100644
--- a/apps/files/tests/js/mainfileinfodetailviewSpec.js
+++ b/apps/files/tests/js/mainfileinfodetailviewSpec.js
@@ -62,7 +62,7 @@ describe('OCA.Files.MainFileInfoDetailView tests', function() {
view.setFileInfo(testFileInfo);
expect(view.$el.find('.fileName h3').text()).toEqual('One.txt');
expect(view.$el.find('.fileName h3').attr('title')).toEqual('One.txt');
- expect(view.$el.find('.size').text()).toEqual('123.5 MB');
+ expect(view.$el.find('.size').text()).toEqual('117.7 MB');
expect(view.$el.find('.size').attr('title')).toEqual('123456789 bytes');
expect(view.$el.find('.date').text()).toEqual('seconds ago');
expect(view.$el.find('.date').attr('title')).toEqual(dateExpected);