I think that the Angular Flex-Layout library is great, but I couldn't figure out how to test its directives like fxHide or fxShow For example, if you have a template like that:
<div fxHide.lt-md class="my-div">Should not be visible for small devices (xs, sm)</div>
How should you mock the screen size values to test it?
So I've found the answer inside the @angular/flex-layout internal unit tests here.
To mock the values you have to inject a mocked version of
MatchMedia
like this:So, you need:
import { ɵMatchMedia as MatchMedia, ɵMockMatchMedia as MockMatchMedia } from '@angular/flex-layout/core';
let mediaController: MockMatchMedia;
mediaController.activate('lt-md');
expect(divDbEl.styles['display']).toEqual('none');