it('has the appropriate label style', function() { assert.equal(label.style.fontSize, '16px', 'has the appropriate font size'); assert.equal(label.style.fontWeight, 'bold', 'has the appropriate font weight'); var dateInput = dateField.firstChild; assert.equal(dateInput.style.width, '6.5em', 'has the appropriate width for the date input'); });
it('has the appropriate description', function() { var descriptionElement = domElement.children[0]; assert.equal(descriptionElement.tagName, 'ACTIVITY-TITLE', 'has the appropriate tag name'); assert.equal(descriptionElement.textContent, descriptionText, 'has the appropriate text'); assert.equal(activity.getDescription(), descriptionText, 'exposes a gettr for the description text'); });
it('has the appropriate default style', function() { assert.equal(domElement.style.border, 'none', 'has no border'); assert.equal(domElement.style.font, 'inherit', 'inherits its font'); assert.equal(domElement.style.padding, '0px', 'has no padding'); assert.equal(label.style.font, 'inherit', 'label inherits its font'); });
it('has the appropriate DOM structure', function() { assert.equal(domElement.tagName, 'SECTION', 'uses a semantic HTML5 tag name'); assert.equal(domElement.getAttribute('widget-name'), widgetName, 'has the appropriate widget name'); assert.equal(container.getAttribute('widget-name'), 'LabeledContainer', 'has a container'); assert.equal(label.textContent, labelText, 'has the appropriate label text'); assert.equal(dateField.tagName, 'DATE-FIELD', 'has a date field'); });
it('has the appropriate style', function() { var style = domElement.style; assert.equal(style.display, 'inline-block', 'has display of inline-block to have the option list postioned appropriately'); assert.equal(style['-webkit-user-select'], 'none', 'has the text unselectable'); });
it('can be setChildWidgets()', function() { activityDetailsSection.setChildWidgets([ document.createElement('another-widget') ]); assert.equal(domElement.children.length, 1, 'has the appropriate number of child elements'); assert.equal(domElement.children[0].tagName, 'ANOTHER-WIDGET', 'the first child is rendered'); });
it('is accessible', function() { assert.equal(domElement.getAttribute('role'), 'region', 'has the appropriate ARIA role'); var sectionTitle = domElement.childNodes[0]; assert.equal(domElement.getAttribute('aria-labelledby'), sectionTitle.id, 'has the appropriate aria-labelledby'); });
it('throws meaningful error messages', function() { assert.throws(function callWithABadTagNameArgument() { var badTagName = 42; domElement = createDOMElement(badTagName); }, 'createDOMElement expects the first argument, tagName, to be a DOM element' ); assert.throws(function callWithABadStyleArgument() { var badStyle = 42; domElement = createDOMElement('thing', badStyle); }, 'createDOMElement expects the second argument, style, to be a hash' ); assert.throws(function callWithABadAttributesArgument() { var goodStyle = {}; var badAttributes = 42; domElement = createDOMElement('thing', goodStyle, badAttributes); }, 'createDOMElement expects the third argument, attributes, to be a hash' ); });
it('works', function() { assert(domElement instanceof HTMLElement, 'creates an HTMLElement'); assert.equal(domElement.tagName, 'SOME-COMPONENT', 'the element has the appropriate tag name'); assert.deepEqual(domElement.style.color, 'green', 'the element gets the passed in style attributes'); assert.deepEqual(domElement.getAttribute('widget-name'), 'SpecialWidget', 'the element gets the passed in attributes'); });
it('can be setValue()', function() { labeledCheckbox.setValue(true); assert.equal(checkbox.checked, true, 'can be checked'); labeledCheckbox.setValue(false); assert.equal(checkbox.checked, false, 'can be unchecked'); });