-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from javierav/feature/tests
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
on: push | ||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ruby: | ||
- '3.0' | ||
- '3.1' | ||
- '3.2' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Ruby ${{ matrix.ruby }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
- name: Run tests | ||
run: rake test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rake/testtask" | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << "test" | ||
t.libs << "lib" | ||
t.test_files = FileList["test/**/*_test.rb"] | ||
end | ||
|
||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require "test_helper" | ||
|
||
class ClassVariantsTest < Minitest::Test | ||
def setup | ||
@cv = ClassVariants.build( | ||
"rounded border", | ||
variants: { | ||
size: { | ||
sm: "text-sm", | ||
md: "text-md" | ||
}, | ||
color: { | ||
red: "text-red", | ||
green: "text-green" | ||
}, | ||
visible: "inline-block", | ||
"!visible": "hidden" | ||
}, | ||
defaults: { | ||
size: :md | ||
} | ||
) | ||
end | ||
|
||
def test_base_with_defaults | ||
assert_equal "rounded border text-md", @cv.render | ||
end | ||
|
||
def test_base_with_defaults_overwrite | ||
assert_equal "rounded border text-sm", @cv.render(size: :sm) | ||
end | ||
|
||
def test_base_with_defaults_overwrite_and_add | ||
assert_equal "rounded border text-sm text-green", @cv.render(size: :sm, color: :green) | ||
end | ||
|
||
def test_boolean_variants | ||
assert_equal "rounded border text-md inline-block", @cv.render(visible: true) | ||
assert_equal "rounded border text-md hidden", @cv.render(visible: false) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$LOAD_PATH.unshift File.expand_path("../lib", __dir__) | ||
require "class_variants" | ||
|
||
require "minitest/autorun" |