{"size": 1641, "ext": "js", "max_stars_repo_path": "chrome/test/data/pdf/viewer_thumbnail_bar_test.js", "max_stars_repo_name": "mghgroup/Glide-Browser", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "chrome/test/data/pdf/viewer_thumbnail_bar_test.js", "max_issues_repo_name": "mghgroup/Glide-Browser", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "chrome/test/data/pdf/viewer_thumbnail_bar_test.js", "max_forks_repo_name": "mghgroup/Glide-Browser", "max_forks_repo_forks_event_min_datetime": "2021-01-05T23:43:46.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-07T23:36:34.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 37.2954545455, "max_line_length": 127, "alphanum_fraction": 0.733698964}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {ViewerThumbnailBarElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/elements/viewer-thumbnail-bar.js';
import {ViewerThumbnailElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/elements/viewer-thumbnail.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

/** @return {!ViewerThumbnailBarElement} */
function createThumbnailBar() {
  document.body.innerHTML = '';
  const thumbnailBar = /** @type {!ViewerThumbnailBarElement} */ (
      document.createElement('viewer-thumbnail-bar'));
  document.body.appendChild(thumbnailBar);
  return thumbnailBar;
}

// Unit tests for the viewer-thumbnail-bar element.
const tests = [
  // Test that the thumbnail bar has the correct number of thumbnails.
  function testNumThumbnails() {
    const testDocLength = 10;
    const thumbnailBar = createThumbnailBar();
    thumbnailBar.docLength = testDocLength;

    flush();

    // Test that the correct number of viewer-thumbnail elements was created.
    const thumbnails =
        /** @type {!NodeList<!ViewerThumbnailElement>} */ (
            thumbnailBar.shadowRoot.querySelectorAll('viewer-thumbnail'));
    chrome.test.assertEq(testDocLength, thumbnails.length);

    // Test that each thumbnail has the correct page number.
    thumbnails.forEach((thumbnail, i) => {
      chrome.test.assertEq(i + 1, thumbnail.pageNumber);
    });

    chrome.test.succeed();
  },
];

chrome.test.runTests(tests);
