Accueil / javascript / 1-js / 05-data-types / 03-string / 3-truncate / _js.view / test.js

test.js

describe("truncate", function() {
  it("truncate the long string to the given length (including the ellipsis)", function() {
    assert.equal(
      truncate("What I'd like to tell on this topic is:", 20),
      "What I'd like to te…"
    );
  });

  it("doesn't change short strings", function() {
    assert.equal(
      truncate("Hi everyone!", 20),
      "Hi everyone!"
    );
  });

});

Exemple