From b163b45a5e26e64ee7ae7d08e74f5c489e4c4451 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 18 Sep 2015 15:10:21 -0700 Subject: [PATCH] [Framework] Update spec Update spec to verify that app.controller et al are not called multiple times with the same key. --- .../test/register/CustomRegistrarsSpec.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/platform/framework/test/register/CustomRegistrarsSpec.js b/platform/framework/test/register/CustomRegistrarsSpec.js index b8380fa575..5083e63f88 100644 --- a/platform/framework/test/register/CustomRegistrarsSpec.js +++ b/platform/framework/test/register/CustomRegistrarsSpec.js @@ -113,6 +113,25 @@ define( // Notably, keys are not needed for run calls }); + it("does not re-register duplicate keys", function () { + // Verify preconditions, invoke, expect to have been called + expect(mockApp.directive.calls.length).toEqual(0); + customRegistrars.directives([{ key: "a" }, { key: "a" }]); + expect(mockApp.directive.calls.length).toEqual(1); + + expect(mockApp.controller.calls.length).toEqual(0); + customRegistrars.controllers([{ key: "c" }, { key: "c" }, { key: "c" }]); + expect(mockApp.controller.calls.length).toEqual(1); + + expect(mockApp.service.calls.length).toEqual(0); + customRegistrars.services([{ key: "b" }, { key: "b" }]); + expect(mockApp.service.calls.length).toEqual(1); + + // None of this should have warned, this is all + // nominal behavior + expect(mockLog.warn.calls.length).toEqual(0); + }); + it("allows routes to be registered", function () { var mockRouteProvider = jasmine.createSpyObj( "$routeProvider", @@ -166,4 +185,4 @@ define( }); }); } -); \ No newline at end of file +);