From 951cad1e11f051533698018ef634085ff9c4fbd7 Mon Sep 17 00:00:00 2001 From: Zanqi Liang Date: Wed, 24 Oct 2012 21:25:15 -0400 Subject: [PATCH 1/3] Unit test for renaming --- test/spec/WorkingSetView-test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index fc975f629..f0627f847 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -227,6 +227,21 @@ define(function (require, exports, module) { expect(listItems.find(".file-status-icon dirty").length).toBe(0); }); }); + + it("should show the file in project tree when a file is being renamed", function () { + runs(function () { + var $ = testWindow.$; + var secondItem = $($("#open-files-container > ul").children()[1]); + var fileName = secondItem.text(); + secondItem.trigger('click'); + + var a = CommandManager.execute(Commands.FILE_RENAME); + + var $projectFileItems = $("#project-files-container > ul").children(); + + expect($projectFileItems.find("a.jstree-clicked").eq(0).siblings("input").eq(0).val() === fileName).toBeTruthy(); + }); + }); }); }); \ No newline at end of file From dab9fae48a1b235cd5e13ab8b8549f7f928713dc Mon Sep 17 00:00:00 2001 From: Zanqi Liang Date: Wed, 24 Oct 2012 21:44:09 -0400 Subject: [PATCH 2/3] Cleanup --- test/spec/WorkingSetView-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index f0627f847..49033bdba 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -235,7 +235,7 @@ define(function (require, exports, module) { var fileName = secondItem.text(); secondItem.trigger('click'); - var a = CommandManager.execute(Commands.FILE_RENAME); + CommandManager.execute(Commands.FILE_RENAME); var $projectFileItems = $("#project-files-container > ul").children(); From cff3e2bd78e44f3486eb0dfba271d8a6ff0821bd Mon Sep 17 00:00:00 2001 From: Zanqi Liang Date: Thu, 25 Oct 2012 22:58:44 -0400 Subject: [PATCH 3/3] Cleanup and add comment --- test/spec/WorkingSetView-test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/spec/WorkingSetView-test.js b/test/spec/WorkingSetView-test.js index 49033bdba..c32733ca3 100644 --- a/test/spec/WorkingSetView-test.js +++ b/test/spec/WorkingSetView-test.js @@ -231,15 +231,18 @@ define(function (require, exports, module) { it("should show the file in project tree when a file is being renamed", function () { runs(function () { var $ = testWindow.$; - var secondItem = $($("#open-files-container > ul").children()[1]); + var secondItem = $("#open-files-container > ul").children().eq(1); var fileName = secondItem.text(); secondItem.trigger('click'); + // Calling FILE_RENAME synchronously works fine here since the item is already visible in project file tree. + // However, if the selected item is not already visible in the tree, this command will complete asynchronously. + // In that case, waitsFor will be needed before continuing with the rest of the test. CommandManager.execute(Commands.FILE_RENAME); var $projectFileItems = $("#project-files-container > ul").children(); - expect($projectFileItems.find("a.jstree-clicked").eq(0).siblings("input").eq(0).val() === fileName).toBeTruthy(); + expect($projectFileItems.find("a.jstree-clicked").eq(0).siblings("input").eq(0).val()).toBe(fileName); }); });