|
| 1 | +require_relative '../../support/utils' |
| 2 | +include Utils |
| 3 | + |
| 4 | +describe 'List Components ul, ol, li', type: :feature, js: true do |
| 5 | + |
| 6 | + it 'Unordered lists' do |
| 7 | + |
| 8 | + class ExamplePage < Page::Cell::Page |
| 9 | + |
| 10 | + def response |
| 11 | + components { |
| 12 | + # simple unordered list |
| 13 | + ul do |
| 14 | + 5.times do |
| 15 | + li text: 'I am simple!' |
| 16 | + end |
| 17 | + end |
| 18 | + |
| 19 | + # advanced unordered list |
| 20 | + ul id: 'custom-unordered-list' do |
| 21 | + li class: 'inline-li-element', text: 'I am inline text' |
| 22 | + li class: 'yield-li-element' do |
| 23 | + plain 'I am yielded plain' |
| 24 | + end |
| 25 | + li class: 'inline-li-element', text: 'I am inline text' |
| 26 | + end |
| 27 | + } |
| 28 | + end |
| 29 | + |
| 30 | + end |
| 31 | + |
| 32 | + visit "/example" |
| 33 | + |
| 34 | + static_output = page.html |
| 35 | + |
| 36 | + expected_static_output = <<~HTML |
| 37 | + <ul> |
| 38 | + <li>I am simple!</li> |
| 39 | + <li>I am simple!</li> |
| 40 | + <li>I am simple!</li> |
| 41 | + <li>I am simple!</li> |
| 42 | + <li>I am simple!</li> |
| 43 | + </ul> |
| 44 | +
|
| 45 | + <ul id="custom-unordered-list"> |
| 46 | + <li class="inline-li-element">I am inline text</li> |
| 47 | + <li class="yield-li-element">I am yielded plain</li> |
| 48 | + <li class="inline-li-element">I am inline text</li> |
| 49 | + </ul> |
| 50 | + HTML |
| 51 | + |
| 52 | + expect(stripped(static_output)).to include(stripped(expected_static_output)) |
| 53 | + end |
| 54 | + |
| 55 | + it 'Ordered list' do |
| 56 | + |
| 57 | + class ExamplePage < Page::Cell::Page |
| 58 | + |
| 59 | + def response |
| 60 | + components { |
| 61 | + # simple ordered list |
| 62 | + ol do |
| 63 | + 5.times do |
| 64 | + li text: 'I am simple!' |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + # advanced ordered list |
| 69 | + ol id: 'custom-ordered-list' do |
| 70 | + li class: 'inline-li-element', text: 'I am inline text' |
| 71 | + li class: 'yield-li-element' do |
| 72 | + plain 'I am yielded plain' |
| 73 | + end |
| 74 | + li class: 'inline-li-element', text: 'I am inline text' |
| 75 | + end |
| 76 | + } |
| 77 | + end |
| 78 | + |
| 79 | + end |
| 80 | + |
| 81 | + visit "/example" |
| 82 | + |
| 83 | + static_output = page.html |
| 84 | + |
| 85 | + expected_static_output = <<~HTML |
| 86 | + <ol> |
| 87 | + <li>I am simple!</li> |
| 88 | + <li>I am simple!</li> |
| 89 | + <li>I am simple!</li> |
| 90 | + <li>I am simple!</li> |
| 91 | + <li>I am simple!</li> |
| 92 | + </ol> |
| 93 | +
|
| 94 | + <ol id="custom-ordered-list"> |
| 95 | + <li class="inline-li-element">I am inline text</li> |
| 96 | + <li class="yield-li-element">I am yielded plain</li> |
| 97 | + <li class="inline-li-element">I am inline text</li> |
| 98 | + </ol> |
| 99 | + HTML |
| 100 | + |
| 101 | + expect(stripped(static_output)).to include(stripped(expected_static_output)) |
| 102 | + end |
| 103 | + |
| 104 | + it 'Nested lists' do |
| 105 | + |
| 106 | + class ExamplePage < Page::Cell::Page |
| 107 | + |
| 108 | + def response |
| 109 | + components { |
| 110 | + # lists within lists |
| 111 | + ul id: 'favorite-dishes-list' do |
| 112 | + ul do |
| 113 | + 3.times do |
| 114 | + li text: 'Pizza over all' |
| 115 | + end |
| 116 | + end |
| 117 | + ol id: 'favorite-breakfast' do |
| 118 | + li class: 'inline-li-element', text: 'Coffee' |
| 119 | + li class: 'yield-li-element' do |
| 120 | + plain 'Muesli' |
| 121 | + end |
| 122 | + li class: 'inline-li-element', text: 'Orange juice' |
| 123 | + end |
| 124 | + li class: 'italian-food', text: 'Pasta is okay, too' |
| 125 | + li class: 'yield-american-dish' do |
| 126 | + plain 'Maybe sometimes burgers' |
| 127 | + end |
| 128 | + li class: 'italian-food', text: 'Lasagna for life' |
| 129 | + end |
| 130 | + } |
| 131 | + end |
| 132 | + |
| 133 | + end |
| 134 | + |
| 135 | + visit "/example" |
| 136 | + |
| 137 | + static_output = page.html |
| 138 | + |
| 139 | + expected_static_output = <<~HTML |
| 140 | + <ul id="favorite-dishes-list"> |
| 141 | + <ul> |
| 142 | + <li>Pizza over all</li> |
| 143 | + <li>Pizza over all</li> |
| 144 | + <li>Pizza over all</li> |
| 145 | + </ul> |
| 146 | + <ol id="favorite-breakfast"> |
| 147 | + <li class="inline-li-element">Coffee</li> |
| 148 | + <li class="yield-li-element">Muesli</li> |
| 149 | + <li class="inline-li-element">Orange juice</li> |
| 150 | + </ol> |
| 151 | + <li class="italian-food">Pasta is okay, too</li> |
| 152 | + <li class="yield-american-dish">Maybe sometimes burgers</li> |
| 153 | + <li class="italian-food">Lasagna for life</li> |
| 154 | + </ul> |
| 155 | + HTML |
| 156 | + |
| 157 | + expect(stripped(static_output)).to include(stripped(expected_static_output)) |
| 158 | + end |
| 159 | + |
| 160 | +end |
0 commit comments