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() {
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);
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);
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');
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);
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);
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() {
s.setSummary({
totalDirs: 5,
totalFiles: 2,
- totalSize: 256000,
+ totalSize: 256*1024,
filter: 'foo'
});
expect($container.hasClass('hidden')).toEqual(false);
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();
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();
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);
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');
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');
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);