alertmanager/ui/app/tests/GroupBar.elm
Andrey Kuzmin 562f99566e Improved Validation (#827)
* Restructure the validation

* Validate on blur

* Extract alerts from the silence

* Use string for the error type

* Use ApiData everywhere

* Validate the form

* Remove redirect on failure

* Code review fixes

* Hide the delete button if there is one matcher

* Rename silence2

* Update bindata.go

* Fix the tests

* Actually hide the delete button

* Update bindata.go
2017-05-28 12:53:25 +02:00

54 lines
1.7 KiB
Elm

module GroupBar exposing (..)
import Test exposing (..)
import Expect
import Views.GroupBar.Match exposing (jaroWinkler, commonPrefix)
testJaroWinkler : Test
testJaroWinkler =
describe "jaroWinkler"
[ test "should find the right values 1" <|
\() ->
Expect.greaterThan (jaroWinkler "zi" "zone")
(jaroWinkler "zo" "zone")
, test "should find the right values 2" <|
\() ->
Expect.greaterThan (jaroWinkler "de" "alertname")
(jaroWinkler "de" "dev")
, test "should find the right values 3" <|
\() ->
Expect.equal 0.0
(jaroWinkler "l" "zone")
, test "should find the right values 4" <|
\() ->
Expect.equal 1.0
(jaroWinkler "zone" "zone")
, test "should find the right values 5" <|
\() ->
Expect.greaterThan 0.688
(jaroWinkler "atleio3tefdoisahdf" "attributefdoiashfoihfeowfh9w8f9afaw9fahw")
]
testCommonPrefix : Test
testCommonPrefix =
describe "commonPrefix"
[ test "should find the commonPrefix 1" <|
\() ->
Expect.equal "zo"
(commonPrefix "zo" "zone")
, test "should find the commonPrefix 2" <|
\() ->
Expect.equal "zo"
(commonPrefix "zol" "zone")
, test "should find the commonPrefix 3" <|
\() ->
Expect.equal ""
(commonPrefix "oon" "zone")
, test "should find the commonPrefix 4" <|
\() ->
Expect.equal "zone"
(commonPrefix "zone123" "zone123")
]