[Pkg-owncloud-commits] [owncloud] 154/199: Added unit test for file action context argument

David Prévot taffit at moszumanska.debian.org
Sun Jun 1 18:53:21 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 8bdce6698cb6a9e71d7bab72e649b63cb9f60bd8
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon May 19 18:47:14 2014 +0200

    Added unit test for file action context argument
---
 apps/files/tests/js/fileactionsSpec.js | 36 ++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index 9152dbb..519a31b 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -78,8 +78,8 @@ describe('OCA.Files.FileActions tests', function() {
 		};
 		var $tr = fileList.add(fileData);
 
-		FileActions.display($tr.find('td.filename'), true);
-		FileActions.display($tr.find('td.filename'), true);
+		FileActions.display($tr.find('td.filename'), true, fileList);
+		FileActions.display($tr.find('td.filename'), true, fileList);
 
 		// actions defined after cal
 		expect($tr.find('.action.action-download').length).toEqual(1);
@@ -98,7 +98,7 @@ describe('OCA.Files.FileActions tests', function() {
 			mtime: '123456'
 		};
 		var $tr = fileList.add(fileData);
-		FileActions.display($tr.find('td.filename'), true);
+		FileActions.display($tr.find('td.filename'), true, fileList);
 
 		$tr.find('.action-download').click();
 
@@ -118,11 +118,39 @@ describe('OCA.Files.FileActions tests', function() {
 			mtime: '123456'
 		};
 		var $tr = fileList.add(fileData);
-		FileActions.display($tr.find('td.filename'), true);
+		FileActions.display($tr.find('td.filename'), true, fileList);
 
 		$tr.find('.action.delete').click();
 
 		expect(deleteStub.calledOnce).toEqual(true);
 		deleteStub.restore();
 	});
+	it('passes context to action handler', function() {
+		var actionStub = sinon.stub();
+		var fileData = {
+			id: 18,
+			type: 'file',
+			name: 'testName.txt',
+			mimetype: 'text/plain',
+			size: '1234',
+			etag: 'a01234c',
+			mtime: '123456'
+		};
+		var $tr = fileList.add(fileData);
+		FileActions.register(
+				'all',
+				'Test',
+				OC.PERMISSION_READ,
+				OC.imagePath('core', 'actions/test'),
+				actionStub
+		);
+		FileActions.display($tr.find('td.filename'), true, fileList);
+		$tr.find('.action-test').click();
+		expect(actionStub.calledOnce).toEqual(true);
+		expect(actionStub.getCall(0).args[0]).toEqual('testName.txt');
+		var context = actionStub.getCall(0).args[1];
+		expect(context.$file.is($tr)).toEqual(true);
+		expect(context.fileList).toBeDefined();
+		expect(context.fileActions).toBeDefined();
+	});
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list