diff options
author | Luflosi <luflosi@luflosi.de> | 2021-07-14 18:04:05 +0200 |
---|---|---|
committer | Luflosi <luflosi@luflosi.de> | 2021-07-18 14:05:57 +0200 |
commit | 703b9b144c5b1ed5bc5057c9277c85f00e801d78 (patch) | |
tree | f51e25afc7f1de4624227c7c50be13b18772de4a /pkgs/development/node-packages/package-tests | |
parent | cd8ad180e62aeb868130514601575424b15f9f6a (diff) |
nodePackages.postcss-cli: add passthru.tests
Diffstat (limited to 'pkgs/development/node-packages/package-tests')
-rw-r--r-- | pkgs/development/node-packages/package-tests/postcss-cli.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pkgs/development/node-packages/package-tests/postcss-cli.nix b/pkgs/development/node-packages/package-tests/postcss-cli.nix new file mode 100644 index 0000000000000..521509e7f43b7 --- /dev/null +++ b/pkgs/development/node-packages/package-tests/postcss-cli.nix @@ -0,0 +1,45 @@ +{ runCommand, postcss-cli }: + +let + inherit (postcss-cli) packageName version; +in + +runCommand "${packageName}-tests" { meta.timeout = 60; } + '' + # get version of installed program and compare with package version + claimed_version="$(${postcss-cli}/bin/postcss --version)" + if [[ "$claimed_version" != "${version}" ]]; then + echo "Error: program version does not match package version ($claimed_version != ${version})" + exit 1 + fi + + # run basic help command + ${postcss-cli}/bin/postcss --help > /dev/null + + # basic autoprefixer test + config_dir="$(mktemp -d)" + clean_up() { + rm -rf "$config_dir" + } + trap clean_up EXIT + echo " + module.exports = { + plugins: { + 'autoprefixer': { overrideBrowserslist: 'chrome 40' }, + }, + } + " > "$config_dir/postcss.config.js" + input='a{ user-select: none; }' + expected_output='a{ -webkit-user-select: none; user-select: none; }' + actual_output="$(echo $input | ${postcss-cli}/bin/postcss --no-map --config $config_dir)" + if [[ "$actual_output" != "$expected_output" ]]; then + echo "Error: autoprefixer did not output the correct CSS:" + echo "$actual_output" + echo "!=" + echo "$expected_output" + exit 1 + fi + + # needed for Nix to register the command as successful + touch $out + '' |