diff options
Diffstat (limited to 'apps/files/tests/js/filelistSpec.js')
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index b7ee9c8554e..ddd9a45d153 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2476,6 +2476,120 @@ describe('OCA.Files.FileList tests', function() { sortStub.restore(); }); + describe('with favorites', function() { + it('shows favorite files on top', function() { + testFiles.push(new FileInfo({ + id: 5, + type: 'file', + name: 'ZZY Before last file in ascending order', + mimetype: 'text/plain', + mtime: 999999998, + size: 9999998, + // Tags would be added by TagsPlugin + tags: [OC.TAG_FAVORITE], + }), new FileInfo({ + id: 6, + type: 'file', + name: 'ZZZ Last file in ascending order', + mimetype: 'text/plain', + mtime: 999999999, + size: 9999999, + // Tags would be added by TagsPlugin + tags: [OC.TAG_FAVORITE], + })); + + fileList.setFiles(testFiles); + + // Sort by name in ascending order (default sorting is by name + // in ascending order, but setFiles does not trigger a sort, so + // the files must be sorted before being set or a sort must be + // triggered afterwards by clicking on the header). + fileList.$el.find('.column-name .columntitle').click(); + fileList.$el.find('.column-name .columntitle').click(); + + expect(fileList.findFileEl('ZZY Before last file in ascending order').index()).toEqual(0); + expect(fileList.findFileEl('ZZZ Last file in ascending order').index()).toEqual(1); + expect(fileList.findFileEl('somedir').index()).toEqual(2); + expect(fileList.findFileEl('One.txt').index()).toEqual(3); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(4); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(5); + + // Sort by size in ascending order + fileList.$el.find('.column-size .columntitle').click(); + fileList.$el.find('.column-size .columntitle').click(); + + expect(fileList.findFileEl('ZZY Before last file in ascending order').index()).toEqual(0); + expect(fileList.findFileEl('ZZZ Last file in ascending order').index()).toEqual(1); + expect(fileList.findFileEl('One.txt').index()).toEqual(2); + expect(fileList.findFileEl('somedir').index()).toEqual(3); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(4); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(5); + + // Sort by modification time in ascending order + fileList.$el.find('.column-mtime .columntitle').click(); + fileList.$el.find('.column-mtime .columntitle').click(); + + expect(fileList.findFileEl('ZZY Before last file in ascending order').index()).toEqual(0); + expect(fileList.findFileEl('ZZZ Last file in ascending order').index()).toEqual(1); + expect(fileList.findFileEl('One.txt').index()).toEqual(2); + expect(fileList.findFileEl('somedir').index()).toEqual(3); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(4); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(5); + }); + it('shows favorite files on top also when using descending order', function() { + testFiles.push(new FileInfo({ + id: 5, + type: 'file', + name: 'AAB Before last file in descending order', + mimetype: 'text/plain', + mtime: 2, + size: 2, + // Tags would be added by TagsPlugin + tags: [OC.TAG_FAVORITE], + }), new FileInfo({ + id: 6, + type: 'file', + name: 'AAA Last file in descending order', + mimetype: 'text/plain', + mtime: 1, + size: 1, + // Tags would be added by TagsPlugin + tags: [OC.TAG_FAVORITE], + })); + + fileList.setFiles(testFiles); + + // Sort by name in descending order + fileList.$el.find('.column-name .columntitle').click(); + + expect(fileList.findFileEl('AAB Before last file in descending order').index()).toEqual(0); + expect(fileList.findFileEl('AAA Last file in descending order').index()).toEqual(1); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(2); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(3); + expect(fileList.findFileEl('One.txt').index()).toEqual(4); + expect(fileList.findFileEl('somedir').index()).toEqual(5); + + // Sort by size in descending order + fileList.$el.find('.column-size .columntitle').click(); + + expect(fileList.findFileEl('AAB Before last file in descending order').index()).toEqual(0); + expect(fileList.findFileEl('AAA Last file in descending order').index()).toEqual(1); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(2); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(3); + expect(fileList.findFileEl('somedir').index()).toEqual(4); + expect(fileList.findFileEl('One.txt').index()).toEqual(5); + + // Sort by modification time in descending order + fileList.$el.find('.column-mtime .columntitle').click(); + + expect(fileList.findFileEl('AAB Before last file in descending order').index()).toEqual(0); + expect(fileList.findFileEl('AAA Last file in descending order').index()).toEqual(1); + expect(fileList.findFileEl('Two.jpg').index()).toEqual(2); + expect(fileList.findFileEl('Three.pdf').index()).toEqual(3); + expect(fileList.findFileEl('somedir').index()).toEqual(4); + expect(fileList.findFileEl('One.txt').index()).toEqual(5); + }); + }); }); describe('create file', function() { var deferredCreate; |