github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/web/elm/tests/PipelineGridLayoutTests.elm (about) 1 module PipelineGridLayoutTests exposing (all) 2 3 import Dashboard.PipelineGrid.Layout exposing (cardSize, layout) 4 import Expect 5 import Test exposing (Test, describe, test, todo) 6 7 8 all : Test 9 all = 10 describe "pipeline grid layout" 11 [ describe "card size" 12 [ test "is wide when pipeline has more than 12 layers of jobs" <| 13 \_ -> 14 cardSize ( 13, 1 ) 15 |> Tuple.first 16 |> Expect.equal 2 17 , test "is super wide when pipeline has more than 24 layers of jobs" <| 18 \_ -> 19 cardSize ( 25, 1 ) 20 |> Tuple.first 21 |> Expect.equal 3 22 , test "is narrow when pipeline has no more than 12 layers of jobs" <| 23 \_ -> 24 cardSize ( 12, 1 ) 25 |> Tuple.first 26 |> Expect.equal 1 27 , test "is tall when pipeline is more than 12 jobs tall" <| 28 \_ -> 29 cardSize ( 1, 13 ) 30 |> Tuple.second 31 |> Expect.equal 2 32 , test "is short when pipeline is very few jobs tall" <| 33 \_ -> 34 cardSize ( 1, 3 ) 35 |> Tuple.second 36 |> Expect.equal 1 37 ] 38 , describe "layout" 39 [ test "unit cards fill available columns" <| 40 \_ -> 41 layout 2 [ ( 1, 1 ), ( 1, 1 ) ] 42 |> Expect.equal 43 [ { spannedColumns = 1 44 , spannedRows = 1 45 , column = 1 46 , row = 1 47 } 48 , { spannedColumns = 1 49 , spannedRows = 1 50 , column = 2 51 , row = 1 52 } 53 ] 54 , test "unit cards wrap rows" <| 55 \_ -> 56 layout 1 [ ( 1, 1 ), ( 1, 1 ) ] 57 |> Expect.equal 58 [ { spannedColumns = 1 59 , spannedRows = 1 60 , column = 1 61 , row = 1 62 } 63 , { spannedColumns = 1 64 , spannedRows = 1 65 , column = 1 66 , row = 2 67 } 68 ] 69 , test "wide cards take up two columns" <| 70 \_ -> 71 layout 2 [ ( 2, 1 ), ( 1, 1 ) ] 72 |> Expect.equal 73 [ { spannedColumns = 2 74 , spannedRows = 1 75 , column = 1 76 , row = 1 77 } 78 , { spannedColumns = 1 79 , spannedRows = 1 80 , column = 1 81 , row = 2 82 } 83 ] 84 , test "wide cards break rows" <| 85 \_ -> 86 layout 2 [ ( 1, 1 ), ( 2, 1 ) ] 87 |> Expect.equal 88 [ { spannedColumns = 1 89 , spannedRows = 1 90 , column = 1 91 , row = 1 92 } 93 , { spannedColumns = 2 94 , spannedRows = 1 95 , column = 1 96 , row = 2 97 } 98 ] 99 , test "overflowing cards don't break rows" <| 100 \_ -> 101 layout 1 [ ( 2, 1 ) ] 102 |> Expect.equal 103 [ { spannedColumns = 2 104 , spannedRows = 1 105 , column = 1 106 , row = 1 107 } 108 ] 109 , test "tall cards take up multiple rows" <| 110 \_ -> 111 layout 1 [ ( 1, 2 ), ( 1, 1 ) ] 112 |> Expect.equal 113 [ { spannedColumns = 1 114 , spannedRows = 2 115 , column = 1 116 , row = 1 117 } 118 , { spannedColumns = 1 119 , spannedRows = 1 120 , column = 1 121 , row = 3 122 } 123 ] 124 , test "the spannedRows of a row is the spannedRows of the tallest card in the row" <| 125 \_ -> 126 layout 2 [ ( 1, 2 ), ( 1, 1 ), ( 1, 1 ) ] 127 |> Expect.equal 128 [ { spannedColumns = 1 129 , spannedRows = 2 130 , column = 1 131 , row = 1 132 } 133 , { spannedColumns = 1 134 , spannedRows = 1 135 , column = 2 136 , row = 1 137 } 138 , { spannedColumns = 1 139 , spannedRows = 1 140 , column = 1 141 , row = 3 142 } 143 ] 144 ] 145 ]