Format files with prettier

This commit is contained in:
Andras Schmelczer 2025-07-06 22:21:17 +01:00
commit 1ce0f9c059
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -1,70 +1,66 @@
import { init, reconcile, reconcileWithHistory } from "./index";
import * as fs from "fs";
import { init, reconcile, reconcileWithHistory } from './index';
import * as fs from 'fs';
describe("reconcile", () => {
it("tries calling functions without init", () => {
expect(() => reconcile("Hello", "Hello world", "Hi world")).toThrow(
/call init()/
);
describe('reconcile', () => {
it('tries calling functions without init', () => {
expect(() => reconcile('Hello', 'Hello world', 'Hi world')).toThrow(/call init()/);
expect(() =>
reconcileWithHistory("Hello", "Hello world", "Hi world")
).toThrow(/call init()/);
});
expect(() => reconcileWithHistory('Hello', 'Hello world', 'Hi world')).toThrow(
/call init()/
);
});
it("call reconcile without cursors", async () => {
await initWasm();
it('call reconcile without cursors', async () => {
await initWasm();
expect(reconcile("Hello", "Hello world", "Hi world").text).toEqual(
"Hi world"
);
});
expect(reconcile('Hello', 'Hello world', 'Hi world').text).toEqual('Hi world');
});
it("call reconcile with cursors", async () => {
await initWasm();
it('call reconcile with cursors', async () => {
await initWasm();
const result = reconcile(
"Hello",
{
text: "Hello world",
cursors: [
{
id: 3,
position: 2,
},
],
},
{
text: "Hi world",
cursors: [
{
id: 4,
position: 0,
},
{ id: 5, position: 3 },
],
}
);
const result = reconcile(
'Hello',
{
text: 'Hello world',
cursors: [
{
id: 3,
position: 2,
},
],
},
{
text: 'Hi world',
cursors: [
{
id: 4,
position: 0,
},
{ id: 5, position: 3 },
],
}
);
expect(result.text).toEqual("Hi world");
expect(result.cursors).toEqual([
{ id: 3, position: 0 },
{ id: 4, position: 0 },
{ id: 5, position: 3 },
]);
});
expect(result.text).toEqual('Hi world');
expect(result.cursors).toEqual([
{ id: 3, position: 0 },
{ id: 4, position: 0 },
{ id: 5, position: 3 },
]);
});
it("call reconcileWithHistory", async () => {
await initWasm();
it('call reconcileWithHistory', async () => {
await initWasm();
const result = reconcileWithHistory("Hello", "Hello world", "Hi world");
const result = reconcileWithHistory('Hello', 'Hello world', 'Hi world');
expect(result.text).toEqual("Hi world");
expect(result.history.length).toBeGreaterThan(0);
});
expect(result.text).toEqual('Hi world');
expect(result.history.length).toBeGreaterThan(0);
});
});
async function initWasm() {
const wasmBin = fs.readFileSync("../pkg/reconcile_bg.wasm");
await init({ module_or_path: wasmBin });
const wasmBin = fs.readFileSync('../pkg/reconcile_bg.wasm');
await init({ module_or_path: wasmBin });
}