Skip to content

Commit

Permalink
fix: isCachingEnabled checks incorrect options object (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbazelczuk committed Dec 4, 2023
1 parent 3a60bca commit dd109bb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/http/HttpRequest.brs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function HttpRequest(options as Object, httpInterceptors = [] as Object) as Obje

' @returns {Boolean}
prototype.isCachingEnabled = function () as Boolean
return getProperty(m.options, "enableCaching", true)
return getProperty(m._options, "enableCaching", true)
end function

prototype.setHeader = sub (name as String, value as Dynamic)
Expand Down
33 changes: 33 additions & 0 deletions src/components/http/_tests/HttpRequest.test.brs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,39 @@ function TestSuite__HttpRequest() as Object
return ts.assertMethodWasCalled("UrlTransfer.asyncCancel")
end function)

ts.addTest("isCachingEnabled - should enable caching by default", function (ts as Object) as String
' Given
options = {
id: "123456",
url: "http://test.com",
method: "GET",
}

' When
request = HttpRequest(options)
request.send()

' Then
return ts.assertTrue(request.isCachingEnabled())
end function)

ts.addTest("isCachingEnabled - should disable caching", function (ts as Object) as String
' Given
options = {
id: "123456",
url: "http://test.com",
method: "GET",
enableCaching: false,
}

' When
request = HttpRequest(options)
request.send()

' Then
return ts.assertFalse(request.isCachingEnabled())
end function)

ts.addTest("cancel - should cancel request", function (ts as Object) as String
' Given
options = {
Expand Down

0 comments on commit dd109bb

Please sign in to comment.