Chromium Code Reviews| Index: chrome/test/data/webui/md_history/test_util.js |
| diff --git a/chrome/test/data/webui/md_history/test_util.js b/chrome/test/data/webui/md_history/test_util.js |
| index acb77f4d03142d9242589f033837ae2174594dd1..a7a93fa951fe7c105f48b835822840d3694859b8 100644 |
| --- a/chrome/test/data/webui/md_history/test_util.js |
| +++ b/chrome/test/data/webui/md_history/test_util.js |
| @@ -10,3 +10,26 @@ function flush(callback) { |
| Polymer.dom.flush(); |
| window.setTimeout(callback, 0); |
| } |
| + |
| +/** |
| + * Create a fake history result with the given timestamp. |
| + * @param {Number} timestamp Timestamp of the entry, in ms since the epoch. |
| + * @param {String} url The URL to set on this entry. |
| + * @return {Object} An object representing a history entry. |
| + */ |
| +function createHistoryEntry(timestamp, url) { |
|
tsergeant
2016/02/12 00:48:56
\ (•◡•) /
This is much nicer, thanks for refactor
|
| + var d = new Date(timestamp); |
| + // Extract domain from url. |
| + var domainMatch = url.replace(/^.+?:\/\//, '').match(/[^/]+/); |
| + var domain = domainMatch ? domainMatch[0] : ''; |
| + return { |
| + allTimestamps: [timestamp], |
| + dateRelativeDay: d.toDateString(), |
| + dateTimeOfDay: d.getHours() + ':' + d.getMinutes(), |
| + domain: domain, |
| + starred: false, |
| + time: timestamp, |
| + title: url, |
| + url: url |
| + }; |
| +} |