* Verifies that the visible text for the test DOM structure. * @param {!Object} assert The QUnit assert object. * @param {string} testName The name of the current test. * @param {!Element} element The element to check the text of. * @param {...string} var_args Variadic args for the expected line
(assert, testName, element, var_args)
| 53 | * of visible text. |
| 54 | */ |
| 55 | function assertTextIs(assert, testName, element, var_args) { |
| 56 | if (!element.parentNode || |
| 57 | // IE sets the parentNode of unattached elements to a document fragment. |
| 58 | element.parentNode.nodeType != goog.dom.NodeType.ELEMENT) { |
| 59 | var testContainer = getTestContainer(); |
| 60 | testContainer.appendChild(createTestDom(element)); |
| 61 | } |
| 62 | |
| 63 | var expected = goog.array.slice(arguments, 3).join('\n'); |
| 64 | var actual = bot.dom.getVisibleText(element); |
| 65 | |
| 66 | assert.strictEqual(actual, expected, |
| 67 | 'Expected: ' + escapeText(expected) + |
| 68 | '\n but was: ' + escapeText(actual) + |
| 69 | '\n raw html:\n' + element.innerHTML + |
| 70 | '\n------\n'); |
| 71 | |
| 72 | function createTestDom(element) { |
| 73 | return goog.dom.createDom('div', {'style': 'width: 25em;'}, |
| 74 | goog.dom.createDom('div', |
| 75 | {'style': [ |
| 76 | 'margin: 0 0.5em;', |
| 77 | 'padding: 0;', |
| 78 | 'font-style: italic;', |
| 79 | 'color: gray;' |
| 80 | ].join('')}, |
| 81 | testName), |
| 82 | goog.dom.createDom('div', { |
| 83 | 'style': 'margin-bottom: 0.5em' |
| 84 | }, element)); |
| 85 | } |
| 86 | |
| 87 | function escapeText(text) { |
| 88 | return text.replace(/\n/g, '\\n');//.replace(/\s/g, '\\s'); |
| 89 | } |
| 90 | } |
nothing calls this directly
no test coverage detected