From 9d38e3602b2faf37d861729c52690ce51b8fee97 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 8 May 2014 22:06:30 +0200 Subject: Namespacing for FileList, FileActions and trashbin app - FileList is now an instantiable class - FileActions is now in namespace - added App class for trashbin app - moved trashbin overrides into classes extending FileList - replaced many static calls with "this." or "self." to make the classes reusable/extendable - new URL parameter "view" to specify which view is shown, for example "files" or "trashbin" - added OC.Util.History utility class in core for handling history - moved URL handling/routing to OCA.Files.App - popstate will correctly update the current view and notify the view of the URL change so it can update the current dir - added JS unitt tests for the trashbin app - fixed public app to work with the new namespaces --- apps/files/tests/js/fileactionsSpec.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'apps/files/tests/js/fileactionsSpec.js') diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index f5eafba509f..23a13be45d4 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -19,20 +19,23 @@ * */ -/* global OC, FileActions, FileList */ -describe('FileActions tests', function() { - var $filesTable; +describe('OCA.Files.FileActions tests', function() { + var $filesTable, fileList; + var FileActions = OCA.Files.FileActions; beforeEach(function() { // init horrible parameters - var $body = $('body'); + var $body = $('#testArea'); $body.append(''); $body.append(''); // dummy files table $filesTable = $body.append('
'); - FileList.files = []; + fileList = new OCA.Files.FileList($('#testArea')); + FileActions.registerDefaultActions(fileList); }); afterEach(function() { + FileActions.clear(); + fileList = undefined; $('#dir, #permissions, #filestable').remove(); }); it('calling display() sets file actions', function() { @@ -47,7 +50,7 @@ describe('FileActions tests', function() { }; // note: FileActions.display() is called implicitly - var $tr = FileList.add(fileData); + var $tr = fileList.add(fileData); // actions defined after call expect($tr.find('.action.action-download').length).toEqual(1); @@ -66,7 +69,7 @@ describe('FileActions tests', function() { etag: 'a01234c', mtime: '123456' }; - var $tr = FileList.add(fileData); + var $tr = fileList.add(fileData); FileActions.display($tr.find('td.filename'), true); FileActions.display($tr.find('td.filename'), true); @@ -87,7 +90,7 @@ describe('FileActions tests', function() { etag: 'a01234c', mtime: '123456' }; - var $tr = FileList.add(fileData); + var $tr = fileList.add(fileData); FileActions.display($tr.find('td.filename'), true); $tr.find('.action-download').click(); @@ -97,7 +100,7 @@ describe('FileActions tests', function() { redirectStub.restore(); }); it('deletes file when clicking delete', function() { - var deleteStub = sinon.stub(FileList, 'do_delete'); + var deleteStub = sinon.stub(fileList, 'do_delete'); var fileData = { id: 18, type: 'file', @@ -107,7 +110,7 @@ describe('FileActions tests', function() { etag: 'a01234c', mtime: '123456' }; - var $tr = FileList.add(fileData); + var $tr = fileList.add(fileData); FileActions.display($tr.find('td.filename'), true); $tr.find('.action.delete').click(); -- cgit v1.2.3