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