Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srsholmes committed Feb 24, 2018
1 parent 656033a commit e03a194
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
16 changes: 16 additions & 0 deletions __tests__/colors_spec.re
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ let () =
[%raw {| 'Hello ' + '\u001b[32m' + 'World' + '\u001b[39m' |}]
)
);
test("colors should not hightlight keyword if no options", () =>
expect(highlightKeyword(None, "Hello World"))
|> toBe([%raw {| 'Hello World' |}])
);
test("colors should apply multiple changes to a string", () =>
expect(colors(~bg=BgRed, ~color=Blue, "start"))
|> toBe(
Expand All @@ -217,6 +221,18 @@ let () =
]
)
);
test(
"changeColorNotKeyword should only change the colors of the words that aren't the keyword",
() =>
expect(
changeColorNotKeyword(
Some(Red),
Some({colorType: Green, word: "World"}),
"Hello World"
)
)
|> toBe(changeColor(Red, "Hello") ++ " World")
);
}
)
);
5 changes: 5 additions & 0 deletions __tests__/colors_utils_spec.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ let () =
test("endWrap", () =>
expect(endWrap("end")) |> toBe({j|\u001b[end|j} ++ "m")
);
test("wrap will throw with incorrect args", () =>
expect(() =>
wrap(["test"], "throw")
) |> toThrow
);
test("bold", () =>
expect(Colors_Utils.bold("bold"))
|> toBe([%raw {| '\u001b[1m' + 'bold' + '\u001b[22m' |}])
Expand Down
13 changes: 11 additions & 2 deletions lib/js/__tests__/colors_spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/js/__tests__/colors_utils_spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world",
"coverage": "nyc report --temp-directory=coverage --reporter=text-lcov | coveralls",
"coverage":
"nyc report --temp-directory=coverage --reporter=text-lcov | coveralls",
"test": "npm run build && jest --coverage",
"watch:jest": "jest --coverage --watchAll"
},
Expand Down

0 comments on commit e03a194

Please sign in to comment.