Skip to content

Add test for group-hover classes #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/fixtures/group_hover.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="group border-indigo-500 hover:bg-white hover:shadow-lg hover:border-transparent">
<p class="text-indigo-600 group-hover:text-gray-900">New Project</p>
<p class="text-indigo-500 group-hover:text-gray-500">Create a new project from a variety of starting templates.</p>
</div>
17 changes: 13 additions & 4 deletions test/purger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase

test "basic purge" do
purged = purged_tailwind_from_fixtures

assert purged !~ /.mt-6 \{/

assert purged =~ /.mt-5 \{/
assert purged =~ /.sm\\:px-6 \{/
assert purged =~ /.translate-x-1\\\/2 \{/
Expand All @@ -29,9 +29,18 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase
assert purged =~ /.focus-within\\\:outline-black\:focus-within \{/
end

test "purge should remove unused group-hover classes" do
purged = purged_tailwind_from_fixtures

assert purged !~ /.group\:hover .group-hover\\\:bg-blue-900 \{/

assert purged =~ /.group\:hover .group-hover\\\:bg-gray-900 \{/
assert purged =~ /.group\:hover .group-hover\\\:bg-red-500 \{/
end

test "purge shouldn't remove placeholder selectors" do
purged = Tailwindcss::Purger.purge \
Pathname.new(__FILE__).join("../../app/assets/stylesheets/tailwind.css").read,
Pathname.new(__FILE__).join("../../app/assets/stylesheets/tailwind.css").read,
keeping_class_names_from_files: Pathname(__dir__).join("fixtures/placeholders.html.erb")

assert purged =~ /.placeholder-transparent\:\:-moz-placeholder \{/
Expand All @@ -42,7 +51,7 @@ class Tailwindcss::PurgerTest < ActiveSupport::TestCase
private
def purged_tailwind_from_fixtures
Tailwindcss::Purger.purge \
Pathname.new(__FILE__).join("../../app/assets/stylesheets/tailwind.css").read,
Pathname.new(__FILE__).join("../../app/assets/stylesheets/tailwind.css").read,
keeping_class_names_from_files: Pathname(__dir__).glob("fixtures/*.html.erb")
end
end