|
| 1 | +import { loadFixture, testVM, nextTick, setData } from '../../../tests/utils'; |
| 2 | + |
| 3 | +describe("input-group", async () => { |
| 4 | + beforeEach(loadFixture(__dirname, "input-group")) |
| 5 | + testVM() |
| 6 | + |
| 7 | + it("should have '.input-group' class on root element", async () => { |
| 8 | + const { app: { $refs } } = window |
| 9 | + |
| 10 | + const refs = ["basic", "components"] |
| 11 | + |
| 12 | + refs.forEach(ref => { |
| 13 | + expect($refs[ref].$el).toHaveClass("input-group") |
| 14 | + }) |
| 15 | + }) |
| 16 | + |
| 17 | + it("should have role 'group' on root element", async () => { |
| 18 | + const { app: { $refs } } = window |
| 19 | + |
| 20 | + const refs = ["basic", "components"] |
| 21 | + |
| 22 | + refs.forEach(ref => { |
| 23 | + expect($refs[ref].$el.getAttribute("role")).toBe("group") |
| 24 | + }) |
| 25 | + }) |
| 26 | + |
| 27 | + it("basic should have left `.input-group-addon` as first child", async () => { |
| 28 | + const { app: { $refs } } = window |
| 29 | + |
| 30 | + const left = $refs.basic.$el.children[0] |
| 31 | + expect(left).toBeDefined() |
| 32 | + expect(left).toHaveClass("input-group-addon") |
| 33 | + }) |
| 34 | + |
| 35 | + it("basic should have content in left `.input-group-addon`", async () => { |
| 36 | + const { app: { $refs } } = window |
| 37 | + |
| 38 | + const left = $refs.basic.$el.children[0] |
| 39 | + expect(left).toBeDefined() |
| 40 | + expect(left.textContent).toContain("$") |
| 41 | + }) |
| 42 | + |
| 43 | + it("basic should have right `.input-group-addon` as last child", async () => { |
| 44 | + const { app: { $refs } } = window |
| 45 | + |
| 46 | + const right = $refs.basic.$el.children[2] |
| 47 | + expect(right).toBeDefined() |
| 48 | + expect(right).toHaveClass("input-group-addon") |
| 49 | + }) |
| 50 | + |
| 51 | + it("basic should have content in right `.input-group-addon`", async () => { |
| 52 | + const { app: { $refs } } = window |
| 53 | + |
| 54 | + const right = $refs.basic.$el.children[2] |
| 55 | + expect(right).toBeDefined() |
| 56 | + expect(right.textContent).toContain(".00") |
| 57 | + }) |
| 58 | + |
| 59 | + it("basic should have input as second child", async () => { |
| 60 | + const { app: { $refs } } = window |
| 61 | + |
| 62 | + const input = $refs.basic.$el.children[1] |
| 63 | + expect(input).toBeDefined() |
| 64 | + expect(input.tagName).toBe("INPUT") |
| 65 | + }) |
| 66 | + |
| 67 | + it("components should have left `.input-group-addon` as first child", async () => { |
| 68 | + const { app: { $refs } } = window |
| 69 | + |
| 70 | + const left = $refs.components.$el.children[0] |
| 71 | + expect(left).toBeDefined() |
| 72 | + expect(left).toHaveClass("input-group-addon") |
| 73 | + }) |
| 74 | + |
| 75 | + it("components should have content in left `.input-group-addon`", async () => { |
| 76 | + const { app: { $refs } } = window |
| 77 | + |
| 78 | + const left = $refs.components.$el.children[0] |
| 79 | + expect(left).toBeDefined() |
| 80 | + expect(left.textContent).toContain("$") |
| 81 | + }) |
| 82 | + |
| 83 | + it("components should have right `.input-group-btn` as last child", async () => { |
| 84 | + const { app: { $refs } } = window |
| 85 | + |
| 86 | + const right = $refs.components.$el.children[2] |
| 87 | + expect(right).toBeDefined() |
| 88 | + expect(right).toHaveClass("input-group-btn") |
| 89 | + }) |
| 90 | + |
| 91 | + it("components should have button in right `.input-group-btn`", async () => { |
| 92 | + const { app: { $refs } } = window |
| 93 | + |
| 94 | + const right = $refs.components.$el.children[2] |
| 95 | + expect(right).toBeDefined() |
| 96 | + const button = right.children[0] |
| 97 | + expect(button).toBeDefined() |
| 98 | + expect(button.tagName).toBe("BUTTON") |
| 99 | + }) |
| 100 | + |
| 101 | + it("components should have input as second child", async () => { |
| 102 | + const { app: { $refs } } = window |
| 103 | + |
| 104 | + const input = $refs.components.$el.children[1] |
| 105 | + expect(input).toBeDefined() |
| 106 | + expect(input.tagName).toBe("INPUT") |
| 107 | + }) |
| 108 | + |
| 109 | + it("large should have '.input-group-lg' class on root element", async () => { |
| 110 | + const { app: { $refs } } = window |
| 111 | + |
| 112 | + expect($refs.large.$el).toHaveClass("input-group-lg") |
| 113 | + }) |
| 114 | + |
| 115 | + it("small should have '.input-group-sm' class on root element", async () => { |
| 116 | + const { app: { $refs } } = window |
| 117 | + |
| 118 | + expect($refs.small.$el).toHaveClass("input-group-sm") |
| 119 | + }) |
| 120 | + |
| 121 | + it("tags should have root Element type of `fieldset'", async () => { |
| 122 | + const { app: { $refs } } = window |
| 123 | + |
| 124 | + const tags = $refs.tags.$el |
| 125 | + expect(tags).toBeDefined() |
| 126 | + expect(tags.tagName).toBe("FIELDSET") |
| 127 | + }) |
| 128 | + |
| 129 | + it("tags should have addon Element type of `span'", async () => { |
| 130 | + const { app: { $refs } } = window |
| 131 | + |
| 132 | + const tags = $refs.tags.$el |
| 133 | + expect(tags).toBeDefined() |
| 134 | + const left = tags.children[0] |
| 135 | + expect(left).toBeDefined() |
| 136 | + expect(left.tagName).toBe("SPAN") |
| 137 | + }) |
| 138 | + |
| 139 | +}); |
0 commit comments