fix(infra): fix fractional indexing edge cases (#8978)

This commit is contained in:
EYHN
2024-12-02 05:31:07 +00:00
parent cee5d02f71
commit 84210dd197
2 changed files with 21 additions and 1 deletions
@@ -57,3 +57,19 @@ test('no postfix', () => {
generateFractionalIndexingKeyBetween('a0', 'a01').startsWith('a00V')
).toBe(true);
});
test('edge cases', () => {
for (let i = 0; i < 100; i++) {
let a = generateFractionalIndexingKeyBetween(null, null);
let b = generateFractionalIndexingKeyBetween(null, null);
if (a > b) {
[a, b] = [b, a];
}
const c = generateFractionalIndexingKeyBetween(a, b);
const d = generateFractionalIndexingKeyBetween(c, b);
expect(a < c).toBeTruthy();
expect(c < b).toBeTruthy();
expect(c < d).toBeTruthy();
expect(d < b).toBeTruthy();
}
});