Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Mar 19, 2024
1 parent 0ad0107 commit e7c8ead
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
39 changes: 17 additions & 22 deletions src/__tests__/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('test chat model', () => {

it('should dispose a ChatModel', () => {
const model = new ChatModel();
model.dispose()
model.dispose();
expect(model.isDisposed).toBeTruthy();
});
});
Expand All @@ -25,7 +25,7 @@ describe('test chat model', () => {
message.body = 'formatted msg';
return message;
}
};
}

let model: IChatModel;
let messages: IMessage[];
Expand All @@ -34,41 +34,36 @@ describe('test chat model', () => {
id: 'message1',
time: Date.now() / 1000,
body: 'message test',
sender: { id: 'user'}
sender: { id: 'user' }
} as IChatMessage;

beforeEach(() => {
messages = [];
})
});

it('should signal incoming message', () => {
model = new ChatModel();
model.incomingMessage.connect(
(sender: IChatModel, message: IMessage) => {
expect(sender).toBe(model);
messages.push(message);
}
);
model.incomingMessage.connect((sender: IChatModel, message: IMessage) => {
expect(sender).toBe(model);
messages.push(message);
});
model.onMessage(msg);
expect(messages).toHaveLength(1);
expect(messages[0]).toBe(msg);
});

it('should format message', () => {
model = new TestChat();
model.incomingMessage.connect(
(sender: IChatModel, message: IMessage) => {
expect(sender).toBe(model);
messages.push(message);
}
);
model.onMessage({...msg} as IChatMessage);
model.incomingMessage.connect((sender: IChatModel, message: IMessage) => {
expect(sender).toBe(model);
messages.push(message);
});
model.onMessage({ ...msg } as IChatMessage);
expect(messages).toHaveLength(1);
expect(messages[0]).not.toBe(msg);
expect((messages[0] as IChatMessage).body).toBe('formatted msg');
})

})
});
});

describe('model config', () => {
it('should have empty config', () => {
Expand All @@ -77,8 +72,8 @@ describe('test chat model', () => {
});

it('should allow config', () => {
const model = new ChatModel({config: {sendWithShiftEnter: true}});
const model = new ChatModel({ config: { sendWithShiftEnter: true } });
expect(model.config.sendWithShiftEnter).toBeTruthy();
});
})
});
});
13 changes: 8 additions & 5 deletions src/__tests__/widgets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* Example of [Jest](https://jestjs.io/docs/getting-started) unit tests
*/

import { IRenderMimeRegistry, RenderMimeRegistry } from "@jupyterlab/rendermime";
import { ChatModel, IChatModel } from "../model";
import { ChatWidget } from "../widgets/chat-widget";
import {
IRenderMimeRegistry,
RenderMimeRegistry
} from '@jupyterlab/rendermime';
import { ChatModel, IChatModel } from '../model';
import { ChatWidget } from '../widgets/chat-widget';

describe('test chat widget', () => {
let model: IChatModel;
Expand All @@ -13,7 +16,7 @@ describe('test chat widget', () => {
beforeEach(() => {
model = new ChatModel();
rmRegistry = new RenderMimeRegistry();
})
});

describe('model instantiation', () => {
it('should create a ChatModel', () => {
Expand All @@ -23,7 +26,7 @@ describe('test chat widget', () => {

it('should dispose a ChatModel', () => {
const widget = new ChatWidget({ model, rmRegistry });
widget.dispose()
widget.dispose();
expect(widget.isDisposed).toBeTruthy();
});

Expand Down

0 comments on commit e7c8ead

Please sign in to comment.