From 1cbd22f616ff8edbe1857d9bd9487bbddb2f100a Mon Sep 17 00:00:00 2001 From: JAGFx Date: Thu, 24 Feb 2022 19:56:46 +0100 Subject: [PATCH] :white_check_mark: #99 add unit test for common telemetry Signed-off-by: JAGFx --- .run/Unit tests.run.xml | 11 ++++ test/unit/src/utils/telemetry/common.spec.js | 53 ++++++++++---------- 2 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 .run/Unit tests.run.xml diff --git a/.run/Unit tests.run.xml b/.run/Unit tests.run.xml new file mode 100644 index 00000000..23543c0d --- /dev/null +++ b/.run/Unit tests.run.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/test/unit/src/utils/telemetry/common.spec.js b/test/unit/src/utils/telemetry/common.spec.js index 7a37021a..e0b8ca2a 100644 --- a/test/unit/src/utils/telemetry/common.spec.js +++ b/test/unit/src/utils/telemetry/common.spec.js @@ -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); + }); });