Keeps cooking. If the time needed to complete the upgrade is less than the upgrade time of the lab the lab work will be done when the building is upgraded, but like the previous poster said, you need to restart clash to have the time take effect (which can be done by simply going on a raid after the building is done upgrading).
The research time is not needed to be less than LAB upgrade time. It will be continued anyway.
example from my own experience:
I start golem 2 (10 days) and after 2 days I reach TH9 and start LAB (5 days) then when LAB finishes my golem have 3 days to finish.