test_getTextAtLineColumn.js 851 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/ */
  4. "use strict";
  5. const {getTextAtLineColumn} = require("devtools/server/actors/styles");
  6. const TEST_DATA = [
  7. {
  8. desc: "simplest",
  9. input: "#id{color:red;background:yellow;}",
  10. line: 1,
  11. column: 5,
  12. expected: {offset: 4, text: "color:red;background:yellow;}"}
  13. },
  14. {
  15. desc: "multiple lines",
  16. input: "one\n two\n three",
  17. line: 3,
  18. column: 3,
  19. expected: {offset: 11, text: "three"}
  20. },
  21. ];
  22. function run_test() {
  23. for (let test of TEST_DATA) {
  24. do_print("Starting test: " + test.desc);
  25. do_print("Input string " + test.input);
  26. let output = getTextAtLineColumn(test.input, test.line, test.column);
  27. deepEqual(output, test.expected);
  28. }
  29. }