Skip to content

Commit

Permalink
test: add e2e tests for format_js and format_sass
Browse files Browse the repository at this point in the history
  • Loading branch information
TymekDev committed Jun 17, 2024
1 parent a672b37 commit 0dca390
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,24 @@ jobs:
cd RhinoApp
Rscript ../test-lint-js.R
- name: format_js() should format JS scripts
if: always()
run: |
cd RhinoApp
Rscript ../test-format-js.R
- name: lint_sass() should detect lint errors in CSS
if: always()
run: |
cd RhinoApp
Rscript ../test-lint-sass.R
- name: format_sass() should format SASS (.scss) scripts
if: always()
run: |
cd RhinoApp
Rscript ../test-format-sass.R
- name: build_js() should build app.min.js
if: always()
run: |
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/test-format-js.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rhino::format_js()

# Create bad scripts and test if formatting returns the expected result
test_file_path <- fs::path("app", "js", "bad-style.js")
cat('const someFunction = (a ,b) => a+ b + "asdf"', file = test_file_path)
rhino::format_js()
testthat::expect_identical(
readLines(test_file_path),
"const someFunction = (a, b) => a + b + 'asdf';"
)

# Clean up
file.remove(test_file_path)
18 changes: 18 additions & 0 deletions tests/e2e/test-format-sass.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rhino::format_sass()

# Create bad scripts and test if formatting returns the expected result
test_file_path <- fs::path("app", "styles", "bad-style.scss")
cat("@import 'asdf';\nx+y{ color: red}", file = test_file_path)
rhino::format_sass()
testthat::expect_identical(
readLines(test_file_path),
c(
'@import "asdf";',
"x + y {",
" color: red;",
"}"
)
)

# Clean up
file.remove(test_file_path)

0 comments on commit 0dca390

Please sign in to comment.