fix: remove unnecessary type assertion (#37930)

* fix: remove uncessary type assertion

* fix: remove as const
This commit is contained in:
Zheeeng 2022-10-11 15:20:37 +08:00 committed by GitHub
parent 8fc5af0d87
commit 5325e19ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -180,10 +180,10 @@ describe('message.config', () => {
}
const [container1, removeContainer1] = createContainer();
const [container2, removeContainer2] = createContainer();
expect((container1 as HTMLDivElement).querySelector('.ant-message-notice')).toBeFalsy();
expect((container2 as HTMLDivElement).querySelector('.ant-message-notice')).toBeFalsy();
expect(container1.querySelector('.ant-message-notice')).toBeFalsy();
expect(container2.querySelector('.ant-message-notice')).toBeFalsy();
message.config({
getContainer: () => container1 as HTMLDivElement,
getContainer: () => container1,
});
const messageText1 = 'mounted in container1';
@ -191,20 +191,16 @@ describe('message.config', () => {
message.info(messageText1);
});
expect(
(container1 as HTMLDivElement).querySelector('.ant-message-notice')?.textContent,
).toEqual(messageText1);
expect(container1.querySelector('.ant-message-notice')?.textContent).toEqual(messageText1);
message.config({
getContainer: () => container2 as HTMLDivElement,
getContainer: () => container2,
});
const messageText2 = 'mounted in container2';
act(() => {
message.info(messageText2);
});
expect(
(container2 as HTMLDivElement).querySelector('.ant-message-notice')?.textContent,
).toEqual(messageText2);
expect(container2.querySelector('.ant-message-notice')?.textContent).toEqual(messageText2);
if (typeof removeContainer1 === 'function') {
removeContainer1();
}