tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_PUIU_title_difference_spotter.js (1728B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /**
      5 * Tests the difference indication for titles.
      6 */
      7 
      8 const TESTS = [
      9  {
     10    title: null,
     11    expected: undefined,
     12  },
     13  {
     14    title: "Short title",
     15    expected: undefined,
     16  },
     17  {
     18    title: "Short title2",
     19    expected: undefined,
     20  },
     21  {
     22    title: "Long title same as another",
     23    expected: undefined,
     24  },
     25  {
     26    title: "Long title same as another",
     27    expected: undefined,
     28  },
     29  {
     30    title: "Long title with difference at the end 1",
     31    expected: 38,
     32  },
     33  {
     34    title: "Long title with difference at the end 2",
     35    expected: 38,
     36  },
     37  {
     38    title: "A long title with difference 123456 in the middle.",
     39    expected: 30,
     40  },
     41  {
     42    title: "A long title with difference 135246 in the middle.",
     43    expected: 30,
     44  },
     45  {
     46    title:
     47      "Some long titles with variable 12345678 differences to 13572468 other titles",
     48    expected: 32,
     49  },
     50  {
     51    title:
     52      "Some long titles with variable 12345678 differences to 15263748 other titles",
     53    expected: 32,
     54  },
     55  {
     56    title:
     57      "Some long titles with variable 15263748 differences to 12345678 other titles",
     58    expected: 32,
     59  },
     60  {
     61    title: "One long title which will be shorter than the other one",
     62    expected: 40,
     63  },
     64  {
     65    title:
     66      "One long title which will be shorter that the other one (not this one)",
     67    expected: 40,
     68  },
     69 ];
     70 
     71 add_task(async function test_difference_finding() {
     72  PlacesUIUtils.insertTitleStartDiffs(TESTS);
     73 
     74  for (let result of TESTS) {
     75    Assert.equal(
     76      result.titleDifferentIndex,
     77      result.expected,
     78      `Should have returned the correct index for "${result.title}"`
     79    );
     80  }
     81 });