babel/packages/babel-parser/test/unit/util/location.skip-bundled.js
Nicolò Ribaudo ad1798ed48
Only bundle the release build, and don't import src in tests (#13978)
* Only bundle the release build, and don't import `src` in tests

* Use file extension to signal skipping

* Remove unnecessary config change

* Fix imports
2021-11-24 10:08:53 -05:00

39 lines
947 B
JavaScript

import { getLineInfo } from "../../../lib/util/location.js";
describe("getLineInfo", () => {
const input = "a\nb\nc\nd\ne\nf\ng\nh\ni";
it("reports correct position", () => {
expect(getLineInfo(input, 7)).toEqual({
column: 1,
line: 4,
});
});
it("reports correct position for first line", () => {
expect(getLineInfo(input, 0)).toEqual({
column: 0,
line: 1,
});
});
const inputArray = ["a", "b", "c", "d", "e", "f", "g", "h", "i"];
const singleCharLineEndings = ["\n", "\r", "\u2028", "\u2029"];
singleCharLineEndings.forEach(ending => {
it(`supports ${escape(ending)} line ending`, () => {
expect(getLineInfo(inputArray.join(ending), 7)).toEqual({
column: 1,
line: 4,
});
});
});
it(`supports ${escape("\r\n")} line ending`, () => {
expect(getLineInfo(inputArray.join("\r\n"), 7)).toEqual({
column: 1,
line: 3,
});
});
});