-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathResolutionDecorator-specs.js
More file actions
59 lines (47 loc) · 1.85 KB
/
Copy pathResolutionDecorator-specs.js
File metadata and controls
59 lines (47 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import '@testing-library/jest-dom';
import {render, screen} from '@testing-library/react';
import {updateBaseFontSize, calculateFontSize} from '../resolution';
import ResolutionDecorator from '../ResolutionDecorator';
describe('ResolutionDecorator Specs', () => {
test('should apply resolution classes to the wrapped component', () => {
const Component = ResolutionDecorator('div');
render(<Component data-testid="component" />);
const div = screen.getByTestId('component').className;
const expected = true;
const actual = div.includes('enact-res-standard') &&
(div.includes('enact-orientation-landscape') || div.includes('enact-orientation-portrait'));
expect(actual).toBe(expected);
});
test('should allow custom screen types', () => {
const name = 'mhd';
const screens = [
{name: name, pxPerRem: 36, width: 1440, height: 920, aspectRatioName: 'hdtv', base: true}
];
const Component = ResolutionDecorator({screenTypes: screens}, 'div');
render(<Component data-testid="component" />);
const div = screen.getByTestId('component');
expect(div).toHaveClass('enact-res-mhd');
});
test('should change the base font size when screenScale prop changed', () => {
const before = 1;
const Component = ResolutionDecorator('div');
const {rerender} = render(<Component data-testid="component" screenScale={before} />);
const after = 2;
rerender(
<Component data-testid="component" screenScale={after} />
);
updateBaseFontSize(calculateFontSize());
const value = document.documentElement.style.fontSize;
const expected = '72px';
expect(value).toBe(expected);
});
test.skip('should update the resolution when the screen is resized', function () {
// TODO: write a test
});
test.skip(
'should not allow dynamic resolution updates when \'dynamic\' config option is false',
function () {
// TODO: write a test
}
);
});