Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Jul 22, 2024
1 parent 890c8cb commit 24e461f
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/languages/json-source-code.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,61 @@ describe("JSONSourceCode", () => {
});
});

describe("getLoc()", () => {
it("should return the loc property of a node", () => {
const loc = {
start: {
line: 1,
column: 1,
offset: 0,
},
end: {
line: 1,
column: 2,
offset: 1,
},
};
const ast = {
type: "Document",
body: {
type: "Object",
properties: [],
},
tokens: [],
loc,
};
const text = "{}";
const sourceCode = new JSONSourceCode({
text,
ast,
});

assert.strictEqual(sourceCode.getLoc(ast), loc);
});
});

describe("getRange()", () => {
it("should return the range property of a node", () => {
const range = [0, 1];
const ast = {
type: "Document",
body: {
type: "Object",
properties: [],
},
tokens: [],
range,
};
const text = "{}";
const sourceCode = new JSONSourceCode({
text,
ast,
});

assert.strictEqual(sourceCode.getRange(ast), range);
});
});

describe("comments", () => {
it("should contain an empty array when parsing JSON", () => {
const file = { body: "{}", path: "test.json" };
Expand Down

0 comments on commit 24e461f

Please sign in to comment.