| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
) |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
describe("Truncate.truncate.TruncateMiddle", function(){ |
| 10 |
|
| 11 |
it("Will not truncate a URL if 'truncateLen' is greater", function(){ |
| 12 |
var truncatedUrl = Autolinker.truncate.TruncateMiddle("http://www.yahoo.com/some/long/path/to/a/file?foo=bar?ignorethis#baz=bee", 999, ".."); |
| 13 |
expect(truncatedUrl).toBe("http://www.yahoo.com/some/long/path/to/a/file?foo=bar?ignorethis#baz=bee"); |
| 14 |
expect(truncatedUrl.length).toBe(72); |
| 15 |
}); |
| 16 |
|
| 17 |
it("Will truncate a simple URL correctly", function(){ |
| 18 |
var truncatedUrl = Autolinker.truncate.TruncateMiddle("http://www.yahoo.com/some/long/path/to/a/file?foo=bar?ignorethis#baz=bee", 60, ".."); |
| 19 |
expect(truncatedUrl).toBe("http://www.yahoo.com/some/lon..le?foo=bar?ignorethis#baz=bee"); |
| 20 |
expect(truncatedUrl.length).toBe(60); |
| 21 |
}); |
| 22 |
|
| 23 |
it("Will truncate a very short URL correctly", function(){ |
| 24 |
var truncatedUrl = Autolinker.truncate.TruncateMiddle("yahoo.com", 4, ".."); |
| 25 |
expect(truncatedUrl).toBe("y..m"); |
| 26 |
expect(truncatedUrl.length).toBe(4); |
| 27 |
}); |
| 28 |
|
| 29 |
it("Will truncate a long URL correctly", function(){ |
| 30 |
var truncatedUrl = Autolinker.truncate.TruncateMiddle("https://www.google.com/search?q=cake&safe=off&es_sm=93&tbas=0&tbs=qdr:d,itp:photo,ic:specific,isc:red,isz:l&tbm=isch&source=lnt&sa=X&ved=0CBQQpwVqFQoTCMCUxfOErMgCFeFrcgodUDwD1w&dpr=1&biw=1920&bih=955", 80, ".."); |
| 31 |
expect(truncatedUrl).toBe("https://www.google.com/search?q=cake&sa..gCFeFrcgodUDwD1w&dpr=1&biw=1920&bih=955"); |
| 32 |
expect(truncatedUrl.length).toBe(80); |
| 33 |
}); |
| 34 |
|
| 35 |
}); |