From e83e570ec1ab26315a32a8b695854e7ce3262e37 Mon Sep 17 00:00:00 2001 From: HarelM Date: Wed, 17 Sep 2025 11:12:56 +0300 Subject: [PATCH] Fix lint --- src/libs/json-path-to-position.test.ts | 114 ++++++++++++------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/libs/json-path-to-position.test.ts b/src/libs/json-path-to-position.test.ts index 9f6df303..84f82dad 100644 --- a/src/libs/json-path-to-position.test.ts +++ b/src/libs/json-path-to-position.test.ts @@ -3,65 +3,65 @@ import { describe, it, expect } from "vitest"; import { jsonPathToPosition } from "./json-path-to-position"; describe("json-path-to-position", () => { - it("should get position of a simple key", () => { - const json = { - "key1": "value1", - "key2": "value2" - }; - const text = JSON.stringify(json); - const ast = jsonToAst(text); - const node = jsonPathToPosition(["key1"], ast); - expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"value1"'); - }); + it("should get position of a simple key", () => { + const json = { + "key1": "value1", + "key2": "value2" + }; + const text = JSON.stringify(json); + const ast = jsonToAst(text); + const node = jsonPathToPosition(["key1"], ast); + expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"value1"'); + }); - it("should get position of second key", () => { - const json = { - "key1": "value1", - "key2": "value2" - }; - const text = JSON.stringify(json); - const ast = jsonToAst(text); - const node = jsonPathToPosition(["key2"], ast); - expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"value2"'); - }); + it("should get position of second key", () => { + const json = { + "key1": "value1", + "key2": "value2" + }; + const text = JSON.stringify(json); + const ast = jsonToAst(text); + const node = jsonPathToPosition(["key2"], ast); + expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"value2"'); + }); - it("should get position key in array", () => { - const json = { - "layers": [ - { - "id": "layer1" - }, { - "id": "layer2" - } - ] - }; - const text = JSON.stringify(json); - const ast = jsonToAst(text); - const node = jsonPathToPosition(["layers", "1", "id"], ast); - expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"layer2"'); - }); + it("should get position key in array", () => { + const json = { + "layers": [ + { + "id": "layer1" + }, { + "id": "layer2" + } + ] + }; + const text = JSON.stringify(json); + const ast = jsonToAst(text); + const node = jsonPathToPosition(["layers", "1", "id"], ast); + expect(text.slice(node!.loc!.start.offset, node!.loc!.end.offset)).toBe('"layer2"'); + }); - it("should return undefined when key does not exist", () => { - const json = { - "layers": [ - { - "id": "layer1" - }, { - "id": "layer2" - } - ] - }; - const text = JSON.stringify(json); - const ast = jsonToAst(text); - const node = jsonPathToPosition(["layers", "2", "id"], ast); - expect(node).toBe(undefined); - }); + it("should return undefined when key does not exist", () => { + const json = { + "layers": [ + { + "id": "layer1" + }, { + "id": "layer2" + } + ] + }; + const text = JSON.stringify(json); + const ast = jsonToAst(text); + const node = jsonPathToPosition(["layers", "2", "id"], ast); + expect(node).toBe(undefined); + }); - it("should return undefined for value type", () => { - const json = 1; - const text = JSON.stringify(json); - const ast = jsonToAst(text); - const node = jsonPathToPosition(["id"], ast); - expect(node).toBe(undefined); - }); + it("should return undefined for value type", () => { + const json = 1; + const text = JSON.stringify(json); + const ast = jsonToAst(text); + const node = jsonPathToPosition(["id"], ast); + expect(node).toBe(undefined); + }); });