Skip to content

Commit

Permalink
#99 add unit test for common telemetry
Browse files Browse the repository at this point in the history
Signed-off-by: JAGFx <[email protected]>
  • Loading branch information
JAGFx committed Feb 24, 2022
1 parent c2cb9a7 commit 1cbd22f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
11 changes: 11 additions & 0 deletions .run/Unit tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Unit tests" type="JavaScriptTestRunnerJest">
<node-interpreter value="project" />
<node-options value="" />
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
<working-dir value="$PROJECT_DIR$" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
</configuration>
</component>
53 changes: 27 additions & 26 deletions test/unit/src/utils/telemetry/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import { $scale } from '@/utils/telemetry/_common.utils';

describe('Telemetry common utils', () => {
const windowWidth = 1920;
const windowHeight = 1080;

global.innerWidth = windowWidth;
global.innerHeight = windowHeight + 41;

test.each([
{
size: {
width: 0,
height: 720
}
},
{
size: {
width: 1280,
height: 0
}
},
{
size: {
width: 0,
height: 0
}
}
])(
'Test $scale must return 1 without skin width or height',
(currentSkin) => {
global.innerWidth = 1920;
global.innerHeight = 1080;
{ size: { width: 2560, height: windowHeight } },
{ size: { width: 0, height: windowHeight } },
{ size: { width: 4096, height: 2048 } },
{ size: { width: windowWidth, height: 2048 } },
{ size: { width: windowWidth, height: 0 } },
{ size: { width: windowWidth, height: windowHeight } },
{ size: { width: 0, height: 0 } }
])('The skin should be reduced', (currentSkin) => {
expect($scale(currentSkin)).toBeLessThan(1);
});

expect($scale(currentSkin)).toBe(1);
}
);
test.each([
{ size: { width: 1280, height: windowHeight } },
{ size: { width: 0, height: windowHeight } },
{ size: { width: 1280, height: 720 } },
{ size: { width: windowWidth, height: 720 } },
{ size: { width: windowWidth, height: 0 } },
{ size: { width: windowWidth, height: windowHeight } },
{ size: { width: 0, height: 0 } }
])('The skin should be enlarged', (currentSkin) => {
expect($scale(currentSkin)).toBeGreaterThanOrEqual(1);
});
});

0 comments on commit 1cbd22f

Please sign in to comment.