html-init.js 759 B

1234567891011121314151617181920212223
  1. QUnit.test( 'htmlInit', function( assert ) {
  2. fizzyUIUtils.htmlInit( NiceGreeter, 'niceGreeter' );
  3. var done = assert.async();
  4. fizzyUIUtils.docReady( function() {
  5. var greeterElems = document.querySelectorAll('[data-greeter-expected]');
  6. for ( var i=0; i < greeterElems.length; i++ ) {
  7. var greeterElem = greeterElems[i];
  8. var attr = greeterElem.getAttribute('data-greeter-expected');
  9. assert.equal( greeterElem.textContent, attr, 'textContent matches options' );
  10. }
  11. done();
  12. });
  13. });
  14. function NiceGreeter( elem, options ) {
  15. this.element = elem;
  16. var greeting = options && options.greeting || 'hello';
  17. var recipient = options && options.recipient || 'world';
  18. this.element.textContent = greeting + ' ' + recipient;
  19. }