# Copyright (c) 2015, InfluxFramework LLC
# License: MIT. See LICENSE

import os

import influxframework
from influxframework.tests.utils import InfluxFrameworkTestCase

from .website_theme import get_scss_paths


class TestWebsiteTheme(InfluxFrameworkTestCase):
	def test_website_theme(self):
		influxframework.delete_doc_if_exists("Website Theme", "test-theme")
		theme = influxframework.get_doc(
			dict(
				doctype="Website Theme",
				theme="test-theme",
				google_font="Inter",
				custom_scss="body { font-size: 16.5px; }",  # this will get minified!
			)
		).insert()

		theme_path = influxframework.get_site_path("public", theme.theme_url[1:])
		with open(theme_path) as theme_file:
			css = theme_file.read()

		self.assertTrue("body{font-size:16.5px}" in css)
		self.assertTrue("fonts.googleapis.com" in css)

	def test_get_scss_paths(self):
		self.assertIn("influxframework/public/scss/website.bundle", get_scss_paths())

	def test_imports_to_ignore(self):
		influxframework.delete_doc_if_exists("Website Theme", "test-theme")
		theme = influxframework.get_doc(
			dict(doctype="Website Theme", theme="test-theme", ignored_apps=[{"app": "influxframework"}])
		).insert()

		self.assertTrue('@import "influxframework/public/scss/website"' not in theme.theme_scss)
