Description: Display the correct debian version of the package
Author: Nilesh Patra <nilesh@debian.org>
Forwarded: not-needed
Last-Update: 2022-01-30
--- a/R/jquery.R
+++ b/R/jquery.R
@@ -9,6 +9,8 @@
 #' @export
 jquery_core <- function(major_version = 3, minified = getOption("shiny.minified", TRUE)) {
   version <- expand_version(major_version)
+  if (version == "")
+	stop("The major version that you seek does not exist on the system!")
   script <- paste0("jquery-", version, if (minified) ".min.js" else ".js")
   htmlDependency(
     "jquery", version,
@@ -19,8 +21,11 @@
 }
 
 expand_version <- function(major_version) {
-  if (major_version == 3) return("3.6.0")
-  if (major_version == 2) return("2.2.4")
-  if (major_version == 1) return("1.12.4")
+  actual_version <- system("dpkg -s libjs-jquery |grep '^Version' | sed -e 's/Version:[[:space:]]//g' | cut -d'.' -f1", intern = TRUE)
+  full_version <- system("dpkg -s libjs-jquery |grep '^Version' | sed -e 's/Version:[[:space:]]//g' | cut -d'+' -f1 | cut -d'-' -f1", intern = TRUE)
+  if (major_version != actual_version)
+	return("")
+  else
+	return(full_version)
   stop("major_version must be 1, 2, or 3.")
 }
--- a/tests/testthat/test-jquery.R
+++ b/tests/testthat/test-jquery.R
@@ -4,11 +4,9 @@
 })
 
 test_that("jquery_core(2) can be rendered", {
-  script <- htmltools::renderDependencies(list(jquery_core(2, minified = FALSE)), "file")
-  expect_snapshot(as.character(script))
+  expect_error(script <- htmltools::renderDependencies(list(jquery_core(2, minified = FALSE)), "file"))
 })
 
 test_that("jquery_core(1) can be rendered", {
-  script <- htmltools::renderDependencies(list(jquery_core(1, minified = TRUE)), "file")
-  expect_snapshot(as.character(script))
+  expect_error(script <- htmltools::renderDependencies(list(jquery_core(1, minified = TRUE)), "file"))
 })
