|
4 | 4 | require "jekyll" |
5 | 5 | require "fileutils" |
6 | 6 | require "time" |
7 | | -require_relative "../_plugins/tailwind_incremental_fix" |
| 7 | +require_relative "../_plugins/postcss_incremental_fix" |
8 | 8 |
|
9 | 9 | describe Jekyll::PostcssTrigger do |
10 | 10 | before do |
|
37 | 37 | end |
38 | 38 | end |
39 | 39 |
|
40 | | - describe "integration: HTML change triggers CSS rebuild" do |
| 40 | + describe "integration: HTML change triggers CSS rebuild" do |
41 | 41 | before do |
42 | 42 | chdir_tempdir |
43 | 43 | create_file("stylesheets/main.css", "/* css */") |
|
61 | 61 |
|
62 | 62 | Jekyll::Hooks.trigger :site, :post_read, @site |
63 | 63 |
|
64 | | - _(Jekyll::PostcssTrigger. last_check_time).wont_be_nil |
| 64 | + _(Jekyll::PostcssTrigger.last_check_time).wont_be_nil |
65 | 65 | _(Jekyll::PostcssTrigger.css_touched).must_equal false |
66 | 66 | end |
67 | 67 |
|
|
71 | 71 |
|
72 | 72 | # First build - establish baseline |
73 | 73 | Jekyll::Hooks.trigger :site, :post_read, @site |
74 | | - first_check_time = Jekyll::PostcssTrigger. last_check_time |
| 74 | + first_check_time = Jekyll::PostcssTrigger.last_check_time |
75 | 75 |
|
76 | 76 | sleep 0.2 |
77 | 77 |
|
78 | 78 | # NOW modify HTML file (after first build) |
79 | 79 | create_file("index.html", "<html>modified</html>") |
80 | | - css_original_mtime = File. mtime("stylesheets/main.css") |
| 80 | + css_original_mtime = File.mtime("stylesheets/main.css") |
81 | 81 |
|
82 | 82 | sleep 0.1 |
83 | 83 |
|
|
90 | 90 |
|
91 | 91 | it "touches CSS when markdown file changes" do |
92 | 92 | # Create markdown file first |
93 | | - create_file("about. md", "# About Page") |
| 93 | + create_file("about.md", "# About Page") |
94 | 94 |
|
95 | 95 | # First build |
96 | 96 | Jekyll::Hooks.trigger :site, :post_read, @site |
|
110 | 110 | _(File.mtime("stylesheets/main.css") > css_original_mtime).must_equal true |
111 | 111 | end |
112 | 112 |
|
| 113 | + it "touches CSS when CSS partial (e.g. _variables.css) changes" do |
| 114 | + # Create CSS partial first |
| 115 | + create_file("stylesheets/_variables.css", ":root { --color: red; }") |
| 116 | + |
| 117 | + # First build |
| 118 | + Jekyll::Hooks.trigger :site, :post_read, @site |
| 119 | + |
| 120 | + sleep 0.2 |
| 121 | + |
| 122 | + # Modify CSS partial |
| 123 | + create_file("stylesheets/_variables.css", ":root { --color: blue; }") |
| 124 | + css_original_mtime = File.mtime("stylesheets/main.css") |
| 125 | + |
| 126 | + sleep 0.1 |
| 127 | + |
| 128 | + # Second build |
| 129 | + Jekyll::Hooks.trigger :site, :post_read, @site |
| 130 | + |
| 131 | + _(Jekyll::PostcssTrigger.css_touched).must_equal true |
| 132 | + _(File.mtime("stylesheets/main.css") > css_original_mtime).must_equal true |
| 133 | + end |
| 134 | + |
| 135 | + it "touches CSS when CSS file in sub-directory (e.g. _components/*.css) changes" do |
| 136 | + # Create CSS file in sub-directory first |
| 137 | + create_file("stylesheets/_components/base.css", ".btn { color: red; }") |
| 138 | + |
| 139 | + # First build |
| 140 | + Jekyll::Hooks.trigger :site, :post_read, @site |
| 141 | + |
| 142 | + sleep 0.2 |
| 143 | + |
| 144 | + # Modify CSS file in sub-directory |
| 145 | + create_file("stylesheets/_components/base.css", ".btn { color: blue; }") |
| 146 | + css_original_mtime = File.mtime("stylesheets/main.css") |
| 147 | + |
| 148 | + sleep 0.1 |
| 149 | + |
| 150 | + # Second build |
| 151 | + Jekyll::Hooks.trigger :site, :post_read, @site |
| 152 | + |
| 153 | + _(Jekyll::PostcssTrigger.css_touched).must_equal true |
| 154 | + _(File.mtime("stylesheets/main.css") > css_original_mtime).must_equal true |
| 155 | + end |
| 156 | + |
113 | 157 | it "touches CSS when layout file changes" do |
114 | 158 | # Create layout file first |
115 | 159 | create_file("_layouts/default.html", "<html>{{ content }}</html>") |
|
0 commit comments