continue-custom/core/test/util/ranges/maxMinPosition.test.ts
Nate Sesti 20bf1bd670
tests (#1501)
* 👷 CI for jetbrains

* default working dir

* changelog

* build binaries

* binary testing setup

* idesettings

* core binary testing

* run binary tests in ci

* remove unused targets

* needs build

* console.log bin contents

* fix ci

* fix win32 binary download

* test

* no linux arm64

* macos latest

* macos-12

* binary permissions

* upload logs

* fix

* upload full folder as binary artifact

* test

* test macos only

* set full execute permissions

* copy sqlite binary

* cd

* it worked!

* build again in test job

* debug

* remove timeout

* info

* log

* log2

* more logs

* catch

* fewer logs

* test all platforms

* test downloaded artifact

* needs build

* updates

* build

* false

* release

* add tag and upload binaryes

* change tag name

* proper artifact upload

* jest updates

* ✅ generate a few unit tests with Continue

* fix imports related to IdeSettings

* run tsc on PRs

* remove shareSession command (unused)

* update release process

* update plugin version

* don't show ghost text when jetbrains completion visible

* run jetbrains ci in main
2024-06-20 20:08:25 -07:00

70 lines
2.3 KiB
TypeScript

import { maxPosition, minPosition } from "../../../util/ranges";
// This file is generated by Continue
interface Position {
line: number;
character: number;
}
describe("Position comparison functions", () => {
let pos1: Position;
let pos2: Position;
let pos3: Position;
let pos4: Position;
beforeAll(() => {
// Setup: Initializing positions
pos1 = { line: 1, character: 5 };
pos2 = { line: 2, character: 3 };
pos3 = { line: 1, character: 7 };
pos4 = { line: 2, character: 3 }; // Same as pos2 to test equality
});
describe("maxPosition", () => {
it("should return the position with the greater line number", () => {
expect(maxPosition(pos1, pos2)).toEqual(pos2);
});
it("should return the position with the greater character number when lines are equal", () => {
expect(maxPosition(pos1, pos3)).toEqual(pos3);
});
it("should return the first position when both positions are equal", () => {
expect(maxPosition(pos2, pos4)).toEqual(pos2);
});
it("should handle positions with negative line numbers", () => {
const posNegative = { line: -1, character: 0 };
expect(maxPosition(posNegative, pos1)).toEqual(pos1);
});
it("should handle positions with negative character numbers", () => {
const posNegativeChar = { line: 1, character: -1 };
expect(maxPosition(posNegativeChar, pos1)).toEqual(pos1);
});
});
describe("minPosition", () => {
it("should return the position with the lesser line number", () => {
expect(minPosition(pos1, pos2)).toEqual(pos1);
});
it("should return the position with the lesser character number when lines are equal", () => {
expect(minPosition(pos1, pos3)).toEqual(pos1);
});
it("should return the first position when both positions are equal", () => {
expect(minPosition(pos2, pos4)).toEqual(pos2);
});
it("should handle positions with negative line numbers", () => {
const posNegative = { line: -1, character: 0 };
expect(minPosition(posNegative, pos1)).toEqual(posNegative);
});
it("should handle positions with negative character numbers", () => {
const posNegativeChar = { line: 1, character: -1 };
expect(minPosition(posNegativeChar, pos1)).toEqual(posNegativeChar);
});
});
});