Make system fonts work more reliably (#8602)

* Make system fonts work more reliably

* Make it more sophisticated

* Missing semicolon

* Apply suggestions

* Fix formatting

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

* Create FontWatcher-test.tsx

* Add actual tests

* Fix some errors

* Apply suggestions

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Fix FontWatcher tests

* Correct test fixture

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
r00ster 2022-05-23 18:29:16 +02:00 committed by GitHub
parent b4d657b21f
commit 5b51efd861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 16 deletions

View file

@ -17,8 +17,24 @@ limitations under the License.
import { ReactWrapper } from "enzyme";
import EventEmitter from "events";
import { ActionPayload } from "../../src/dispatcher/payloads";
import defaultDispatcher from "../../src/dispatcher/dispatcher";
import { DispatcherAction } from "../../src/dispatcher/actions";
export const emitPromise = (e: EventEmitter, k: string | symbol) => new Promise(r => e.once(k, r));
export function untilDispatch(waitForAction: DispatcherAction): Promise<ActionPayload> {
let dispatchHandle: string;
return new Promise<ActionPayload>(resolve => {
dispatchHandle = defaultDispatcher.register(payload => {
if (payload.action === waitForAction) {
defaultDispatcher.unregister(dispatchHandle);
resolve(payload);
}
});
});
}
const findByAttr = (attr: string) => (component: ReactWrapper, value: string) => component.find(`[${attr}="${value}"]`);
export const findByTestId = findByAttr('data-test-id');
export const findById = findByAttr('id');