Format files with prettier
This commit is contained in:
parent
a2df120e66
commit
1ce0f9c059
1 changed files with 5995 additions and 6004 deletions
|
|
@ -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 });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue