From 02f73cf58e2641f0229a5d200b95b6cfa09ac22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B8rge=20Nordli?= Date: Fri, 12 Jun 2015 13:09:52 +0200 Subject: [PATCH] Check for observable parameters when computing areAllParametersSet in Query.js --- .../Bifrost.JavaScript.Specs.csproj | 1 + ...and_one_observable_parameter_is_not_set.js | 22 +++++++++++++++++++ Source/Bifrost.JavaScript/Bifrost.debug.js | 2 +- Source/Bifrost.JavaScript/read/Query.js | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 Source/Bifrost.JavaScript.Specs/read/for_Query/when_asking_if_all_parameters_are_set_and_one_observable_parameter_is_not_set.js diff --git a/Source/Bifrost.JavaScript.Specs/Bifrost.JavaScript.Specs.csproj b/Source/Bifrost.JavaScript.Specs/Bifrost.JavaScript.Specs.csproj index 4549b3ea2..cd639ea17 100644 --- a/Source/Bifrost.JavaScript.Specs/Bifrost.JavaScript.Specs.csproj +++ b/Source/Bifrost.JavaScript.Specs/Bifrost.JavaScript.Specs.csproj @@ -166,6 +166,7 @@ + diff --git a/Source/Bifrost.JavaScript.Specs/read/for_Query/when_asking_if_all_parameters_are_set_and_one_observable_parameter_is_not_set.js b/Source/Bifrost.JavaScript.Specs/read/for_Query/when_asking_if_all_parameters_are_set_and_one_observable_parameter_is_not_set.js new file mode 100644 index 000000000..1c40bb00a --- /dev/null +++ b/Source/Bifrost.JavaScript.Specs/read/for_Query/when_asking_if_all_parameters_are_set_and_one_observable_parameter_is_not_set.js @@ -0,0 +1,22 @@ +describe("when asking if all parameters are set and one observable parameter is not set", function () { + + var queryType = Bifrost.read.Query.extend(function () { + var self = this; + + this.firstParameter = ko.observable(1); + this.secondParameter = ko.observable(ko.observable()); + }); + + var queryableFactory = {}; + var region = {}; + + var instance = queryType.create({ + queryableFactory: queryableFactory, + region: region + }); + var result = instance.areAllParametersSet(); + + it("should return false", function () { + expect(result).toBe(false); + }); +}); \ No newline at end of file diff --git a/Source/Bifrost.JavaScript/Bifrost.debug.js b/Source/Bifrost.JavaScript/Bifrost.debug.js index 3935e771e..6cb650e1d 100644 --- a/Source/Bifrost.JavaScript/Bifrost.debug.js +++ b/Source/Bifrost.JavaScript/Bifrost.debug.js @@ -5862,7 +5862,7 @@ Bifrost.namespace("Bifrost.read", { for (var property in self.target) { if (ko.isObservable(self.target[property]) === true) { hasParameters = true; - var value = self.target[property](); + var value = ko.unwrap(self.target[property]()); if (typeof value === "undefined" || value === null) { isSet = false; break; diff --git a/Source/Bifrost.JavaScript/read/Query.js b/Source/Bifrost.JavaScript/read/Query.js index fe54b39eb..df9387fc9 100644 --- a/Source/Bifrost.JavaScript/read/Query.js +++ b/Source/Bifrost.JavaScript/read/Query.js @@ -79,7 +79,7 @@ for (var property in self.target) { if (ko.isObservable(self.target[property]) === true) { hasParameters = true; - var value = self.target[property](); + var value = ko.unwrap(self.target[property]()); if (typeof value === "undefined" || value === null) { isSet = false; break;