make PartCreator a bit more testable by not asking for deps of dep

This commit is contained in:
Bruno Windels 2019-07-25 13:33:42 +02:00
parent 419c800167
commit 9bfba9db3e
2 changed files with 16 additions and 10 deletions

View file

@ -117,7 +117,8 @@ class BasePart {
}
}
class PlainPart extends BasePart {
// exported for unit tests, should otherwise only be used through PartCreator
export class PlainPart extends BasePart {
acceptsInsertion(chr) {
return chr !== "@" && chr !== "#" && chr !== ":" && chr !== "\n";
}
@ -348,18 +349,24 @@ class PillCandidatePart extends PlainPart {
}
}
export class PartCreator {
constructor(getAutocompleterComponent, updateQuery, room, client) {
this._room = room;
this._client = client;
this._autoCompleteCreator = (updateCallback) => {
export function autoCompleteCreator(updateQuery, getAutocompleterComponent) {
return (partCreator) => {
return (updateCallback) => {
return new AutocompleteWrapperModel(
updateCallback,
getAutocompleterComponent,
updateQuery,
this,
partCreator,
);
};
};
}
export class PartCreator {
constructor(autoCompleteCreator, room, client) {
this._room = room;
this._client = client;
this._autoCompleteCreator = autoCompleteCreator(this);
}
createPartForInput(input) {