mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-13 07:31:37 +08:00
Unnest client tests
This commit is contained in:
parent
1b1f352f29
commit
85c8b3e7ec
3 changed files with 349 additions and 355 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import Delta from "../../js/lib/delta";
|
||||
|
||||
describe("Delta", () => {
|
||||
describe("compose", () => {
|
||||
describe("compose", () => {
|
||||
test("insert with insert", () => {
|
||||
const a = new Delta().insert("A");
|
||||
const b = new Delta().insert("B");
|
||||
|
|
@ -111,9 +110,9 @@ describe("Delta", () => {
|
|||
|
||||
expect(a.compose(b)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("transform", () => {
|
||||
describe("transform", () => {
|
||||
test("insert against insert", () => {
|
||||
const a = new Delta().insert("A");
|
||||
const b = new Delta().insert("B");
|
||||
|
|
@ -251,9 +250,9 @@ describe("Delta", () => {
|
|||
expect(a).toEqual(new Delta().insert("A"));
|
||||
expect(b).toEqual(new Delta().insert("B"));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyToString", () => {
|
||||
describe("applyToString", () => {
|
||||
test("prepend", () => {
|
||||
const string = "cats";
|
||||
const delta = new Delta().insert("fat ");
|
||||
|
|
@ -281,9 +280,9 @@ describe("Delta", () => {
|
|||
const result = delta.applyToString(string);
|
||||
expect(result).toEqual("cars");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("transformPosition", () => {
|
||||
describe("transformPosition", () => {
|
||||
it("insert before position", () => {
|
||||
const delta = new Delta().insert("A");
|
||||
expect(delta.transformPosition(2)).toEqual(3);
|
||||
|
|
@ -328,5 +327,4 @@ describe("Delta", () => {
|
|||
const delta = new Delta().delete(1).retain(1).delete(4);
|
||||
expect(delta.transformPosition(4)).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Emitter from "../../js/lib/emitter";
|
||||
|
||||
describe("Emitter", () => {
|
||||
test("listener callbacks are called on dispatch", () => {
|
||||
test("listener callbacks are called on dispatch", () => {
|
||||
const emitter = new Emitter();
|
||||
const callback1 = jest.fn();
|
||||
const callback2 = jest.fn();
|
||||
|
|
@ -12,9 +11,9 @@ describe("Emitter", () => {
|
|||
|
||||
expect(callback1).toHaveBeenCalledWith({ data: 1 });
|
||||
expect(callback2).toHaveBeenCalledWith({ data: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
test("addListener returns a subscription object that can be destroyed", () => {
|
||||
test("addListener returns a subscription object that can be destroyed", () => {
|
||||
const emitter = new Emitter();
|
||||
const callback1 = jest.fn();
|
||||
|
||||
|
|
@ -23,5 +22,4 @@ describe("Emitter", () => {
|
|||
emitter.dispatch({});
|
||||
|
||||
expect(callback1).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import PubSub from "../../js/lib/pubsub";
|
||||
|
||||
describe("PubSub", () => {
|
||||
test("subscribed callback is called on the specified topic", () => {
|
||||
test("subscribed callback is called on the specified topic", () => {
|
||||
const pubsub = new PubSub();
|
||||
const callback1 = jest.fn();
|
||||
const callback2 = jest.fn();
|
||||
|
|
@ -12,9 +11,9 @@ describe("PubSub", () => {
|
|||
|
||||
expect(callback1).toHaveBeenCalledWith({ data: 1 });
|
||||
expect(callback2).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
test("subscribe returns a subscription object that can be destroyed", () => {
|
||||
test("subscribe returns a subscription object that can be destroyed", () => {
|
||||
const pubsub = new PubSub();
|
||||
const callback1 = jest.fn();
|
||||
|
||||
|
|
@ -23,5 +22,4 @@ describe("PubSub", () => {
|
|||
pubsub.broadcast("topic1", {});
|
||||
|
||||
expect(callback1).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue