from django.test import TestCase

from bootstrap4.bootstrap import get_bootstrap_setting, include_jquery, jquery_slim_url, jquery_url


class SettingsTest(TestCase):
    def test_get_bootstrap_setting(self):
        self.assertIsNone(get_bootstrap_setting("SETTING_DOES_NOT_EXIST"))
        self.assertEqual("not none", get_bootstrap_setting("SETTING_DOES_NOT_EXIST", "not none"))
        # Override a setting
        with self.settings(BOOTSTRAP4={"SETTING_DOES_NOT_EXIST": "exists now"}):
            self.assertEqual(get_bootstrap_setting("SETTING_DOES_NOT_EXIST"), "exists now")

    def test_jquery_url(self):
        self.assertEqual(
            jquery_url(),
            {
                "url": "https://code.jquery.com/jquery-3.3.1.min.js",
                "integrity": "sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT",
                "crossorigin": "anonymous",
            },
        )

    def test_jquery_slim_url(self):
        self.assertEqual(
            jquery_slim_url(),
            {
                "url": "https://code.jquery.com/jquery-3.3.1.slim.min.js",
                "integrity": "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo",
                "crossorigin": "anonymous",
            },
        )

    def test_include_jquery(self):
        self.assertEqual(include_jquery(), False)
        with self.settings(BOOTSTRAP4={"include_jquery": False}):
            self.assertEqual(include_jquery(), False)
        with self.settings(BOOTSTRAP4={"include_jquery": True}):
            self.assertEqual(include_jquery(), True)
        with self.settings(BOOTSTRAP4={"include_jquery": "full"}):
            self.assertEqual(include_jquery(), "full")
        with self.settings(BOOTSTRAP4={"include_jquery": "slim"}):
            self.assertEqual(include_jquery(), "slim")

@@ -25,16 +25,35 @@
 TestCase
+, override_settings
 %0A%0Afrom b
@@ -929,32 +929,591 @@
   %7D,%0A        )%0A%0A
+    @override_settings(%0A        BOOTSTRAP4=%7B%0A            %22jquery_url%22: %7B%0A                %22url%22: %22https://example.com/jquery.js%22,%0A                %22integrity%22: %22we-want-a-different-jquery%22,%0A                %22crossorigin%22: %22anonymous%22,%0A            %7D,%0A        %7D%0A    )%0A    def test_jquery_url_from_settings(self):%0A        self.assertEqual(%0A            jquery_url(),%0A            %7B%0A                %22url%22: %22https://example.com/jquery.js%22,%0A                %22integrity%22: %22we-want-a-different-jquery%22,%0A                %22crossorigin%22: %22anonymous%22,%0A            %7D,%0A        )%0A%0A
     def test_jqu

Add test for different jQuery version (#184) (#187)