module('title-format');

test('null getFormattedTitle if title-format is missing', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  equal(time.getFormattedTitle(), null);
});

test('null getFormattedTitle if datetime is missing', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('title-format', '%Y-%m-%d %H:%M');
  equal(time.getFormattedTitle(), null);
});

test('getFormattedTitle with title-formatted datetime', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  time.setAttribute('title-format', '%Y-%m-%d');
  equal(time.getFormattedTitle(), window.epochLocalDate);
});

test('skips setting a title if title-format is missing', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  equal(time.getAttribute('title'), null);
});

test('skips setting a title if datetime is missing', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('title-format', '%Y-%m-%d %H:%M');
  equal(time.getAttribute('title'), null);
});

test('sets the title title-formatted datetime', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  time.setAttribute('title-format', '%Y-%m-%d');
  equal(time.getAttribute('title'), window.epochLocalDate);
});

test('set the title when parsed element is upgraded', function() {
  var root = document.createElement('div');
  root.innerHTML = '<time is="local-time" datetime="1970-01-01T00:00:00.000Z"' +
    ' title-format="%Y-%m-%d"></time>';
  if ('CustomElements' in window) {
    window.CustomElements.upgradeSubtree(root);
  }
  equal(root.children[0].getAttribute('title'), window.epochLocalDate);
});

test('updates title if title-formatted changes', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  time.setAttribute('title-format', '%Y-%m-%d');
  equal(time.getAttribute('title'), window.epochLocalDate);
  time.setAttribute('title-format', '%Y');
  equal(time.getAttribute('title'), window.epochLocalYear);
});

test('updates title if datetime changes', function() {
  var time = document.createElement('time', 'local-time');
  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');
  time.setAttribute('title-format', '%Y-%m-%d');
  equal(time.getAttribute('title'), window.epochLocalDate);
  time.setAttribute('datetime', '1971-01-01T00:00:00.000Z');
  equal(time.getAttribute('title'), window.yearAfterEpochLocalDate);
});

@@ -775,32 +775,318 @@
 ocalDate);%0A%7D);%0A%0A
+test('getFormattedTitle with %25z timezone offset', function() %7B%0A  var time = document.createElement('time', 'local-time');%0A  time.setAttribute('datetime', '1970-01-01T00:00:00.000Z');%0A  time.setAttribute('title-format', '%25z');%0A  ok(time.getFormattedTitle().match(/%5C-%5Cd%5Cd%5Cd%5Cd/)%5B0%5D);%0A%7D);%0A%0A
 test('skips sett

Add %z test.