Hash :
982f213c
Author :
Date :
2022-03-28T10:51:42
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
defmodule DartSassTest do
use ExUnit.Case, async: true
@version "1.49.0"
test "run on default" do
assert ExUnit.CaptureIO.capture_io(fn ->
assert DartSass.run(:default, ["--version"]) == 0
end) =~ @version
end
test "run on profile" do
assert ExUnit.CaptureIO.capture_io(fn ->
assert DartSass.run(:another, []) == 0
end) =~ @version
end
test "updates on install" do
Application.put_env(:dart_sass, :version, "1.43.3")
Mix.Task.rerun("sass.install", ["--if-missing"])
assert ExUnit.CaptureIO.capture_io(fn ->
assert DartSass.run(:default, ["--version"]) == 0
end) =~ "1.43.3"
Application.delete_env(:dart_sass, :version)
Mix.Task.rerun("sass.install", ["--if-missing"])
assert ExUnit.CaptureIO.capture_io(fn ->
assert DartSass.run(:default, ["--version"]) == 0
end) =~ @version
end
test "errors on invalid profile" do
assert_raise ArgumentError,
~r<unknown dart_sass profile. Make sure the profile named :"assets/css/app.scss" is defined>,
fn ->
assert DartSass.run(:"assets/css/app.scss", ["../priv/static/assets/app.css"])
end
end
@tag :tmp_dir
test "compiles", %{tmp_dir: dir} do
dest = Path.join(dir, "app.css")
Mix.Task.rerun("sass", ["default", "--no-source-map", "test/fixtures/app.scss", dest])
assert File.read!(dest) == "body > p {\n color: green;\n}\n"
end
end