From 67bfbab4aad0921db7b3202146a4db16cf04f8a5 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 14 Sep 2023 22:12:58 +0200 Subject: [PATCH] Add dprint tests --- test/formatter/dprint_spec.lua | 18 ++++++++++++++++++ test/setup.sh | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/formatter/dprint_spec.lua diff --git a/test/formatter/dprint_spec.lua b/test/formatter/dprint_spec.lua new file mode 100644 index 0000000..b2477a5 --- /dev/null +++ b/test/formatter/dprint_spec.lua @@ -0,0 +1,18 @@ +describe('dprint', function() + it('can format', function() + local ft = require('guard.filetype') + ft('typescriptreact'):fmt('dprint') + require('guard').setup() + + local formatted = require('test.formatter.helper').test_with('typescriptreact', { + [[ const randomNumber = Math.floor(]], + [[ Math.random() * 10]], + [[ ) + 1]], + [[alert(randomNumber)]], + }) + assert.are.same({ + [[const randomNumber = Math.floor(Math.random() * 10) + 1;]], + [[alert(randomNumber);]], + }, formatted) + end) +end) diff --git a/test/setup.sh b/test/setup.sh index afc3c74..f14b6ca 100644 --- a/test/setup.sh +++ b/test/setup.sh @@ -10,7 +10,8 @@ luarocks install luacheck & go install github.com/segmentio/golines@latest & pip -qqq install autopep8 black djhtml isort pylint yapf & npm install -g --silent \ - prettier @fsouza/prettierd sql-formatter shellcheck shfmt & + prettier @fsouza/prettierd sql-formatter shellcheck shfmt dprint & +dprint config add typescript & gem install -q rubocop & brew install \ swiftformat swift-format hadolint google-java-format pgformatter fnlfmt # Block, homebrew takes the longest time