From d33344dacdd094c339f5594dabf17f237b747975 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 14 Jan 2015 13:10:05 -0800 Subject: [PATCH] [About] Add tests for controllers Add tests for controllers introduced to support a minimal implementation of an About dialog, WTD-667. --- .../about/test/AboutControllerSpec.js | 39 +++++++++++++++++++ .../commonUI/about/test/LogoControllerSpec.js | 32 +++++++++++++++ platform/commonUI/about/test/suite.json | 4 ++ 3 files changed, 75 insertions(+) create mode 100644 platform/commonUI/about/test/AboutControllerSpec.js create mode 100644 platform/commonUI/about/test/LogoControllerSpec.js create mode 100644 platform/commonUI/about/test/suite.json diff --git a/platform/commonUI/about/test/AboutControllerSpec.js b/platform/commonUI/about/test/AboutControllerSpec.js new file mode 100644 index 0000000000..1587b42054 --- /dev/null +++ b/platform/commonUI/about/test/AboutControllerSpec.js @@ -0,0 +1,39 @@ +/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ + +define( + ['../src/AboutController'], + function (AboutController) { + "use strict"; + + describe("The About controller", function () { + var testVersions, + mockWindow, + controller; + + beforeEach(function () { + testVersions = [ + { name: "Some name", value: "1.2.3" }, + { name: "Some other name", value: "3.2.1" } + ]; + mockWindow = jasmine.createSpyObj("$window", ["open"]); + controller = new AboutController(testVersions, mockWindow); + }); + + it("exposes version information", function () { + // This will be injected, so it should just give back + // what it got in. + expect(controller.versions()).toEqual(testVersions); + }); + + it("opens license information in a window", function () { + //Verify precondition + expect(mockWindow.open).not.toHaveBeenCalled(); + controller.openLicenses(); + expect(mockWindow.open).toHaveBeenCalledWith("#/licenses"); + }); + + + }); + + } +); \ No newline at end of file diff --git a/platform/commonUI/about/test/LogoControllerSpec.js b/platform/commonUI/about/test/LogoControllerSpec.js new file mode 100644 index 0000000000..f3afb2ab57 --- /dev/null +++ b/platform/commonUI/about/test/LogoControllerSpec.js @@ -0,0 +1,32 @@ +/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ + +define( + ['../src/LogoController'], + function (LogoController) { + "use strict"; + + describe("The About controller", function () { + var mockOverlayService, + controller; + + beforeEach(function () { + mockOverlayService = jasmine.createSpyObj( + "overlayService", + ["createOverlay"] + ); + controller = new LogoController(mockOverlayService); + }); + + it("shows the about dialog", function () { + //Verify precondition + expect(mockOverlayService.createOverlay) + .not.toHaveBeenCalled(); + controller.showAboutDialog(); + expect(mockOverlayService.createOverlay) + .toHaveBeenCalledWith("overlay-about"); + }); + + }); + + } +); \ No newline at end of file diff --git a/platform/commonUI/about/test/suite.json b/platform/commonUI/about/test/suite.json new file mode 100644 index 0000000000..e626ff9b7a --- /dev/null +++ b/platform/commonUI/about/test/suite.json @@ -0,0 +1,4 @@ +[ + "AboutController", + "LogoController" +] \ No newline at end of file