15
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
*/
17
17
18
- import {
19
- getCurrentFontSize ,
20
- resetFontSize ,
21
- INCREMENT
22
- } from '@/utils/font-size'
18
+ import { INCREMENT } from '@/utils/font-size'
19
+
20
+ /** @param {number } expected font size in px */
21
+ function expectFontSize ( expected ) {
22
+ cy . get ( 'html' )
23
+ . should ( 'have.css' , 'font-size' , `${ expected } px` )
24
+ }
23
25
24
26
describe ( 'User Profile' , ( ) => {
25
27
const defaultFontSize = 16 // px
26
28
beforeEach ( ( ) => {
27
- resetFontSize ( )
29
+ // resetFontSize()
28
30
cy . visit ( '/#/user-profile' )
29
31
} )
30
32
@@ -35,43 +37,38 @@ describe('User Profile', () => {
35
37
} )
36
38
37
39
it ( 'Increases the font size' , ( ) => {
38
- expect ( getCurrentFontSize ( ) ) . to . equal ( defaultFontSize )
40
+ expectFontSize ( defaultFontSize )
39
41
const clicks = 3
40
- cy . get ( 'button#font-size-increase-button' ) . then ( ( $button ) => {
41
- for ( let i = 0 ; i < clicks ; i ++ ) {
42
- $button . trigger ( 'click' )
43
- }
44
- const expectedFontSize = defaultFontSize + INCREMENT * clicks
45
- expect ( getCurrentFontSize ( ) ) . to . equal ( expectedFontSize )
46
- } )
42
+ let expectedFontSize = defaultFontSize
43
+ for ( let i = 0 ; i < clicks ; i ++ ) {
44
+ expectedFontSize += INCREMENT
45
+ cy . get ( 'button#font-size-increase-button' )
46
+ . click ( )
47
+ expectFontSize ( expectedFontSize )
48
+ }
47
49
} )
48
50
49
51
it ( 'Decreases the font size' , ( ) => {
50
- expect ( getCurrentFontSize ( ) ) . to . equal ( defaultFontSize )
52
+ expectFontSize ( defaultFontSize )
51
53
const clicks = 3
52
- cy . get ( 'button#font-size-decrease-button' ) . then ( ( $button ) => {
53
- for ( let i = 0 ; i < clicks ; i ++ ) {
54
- $button . trigger ( 'click' )
55
- }
56
- const expectedFontSize = defaultFontSize - INCREMENT * clicks
57
- expect ( getCurrentFontSize ( ) ) . to . equal ( expectedFontSize )
58
- } )
54
+ let expectedFontSize = defaultFontSize
55
+ for ( let i = 0 ; i < clicks ; i ++ ) {
56
+ expectedFontSize -= INCREMENT
57
+ cy . get ( 'button#font-size-decrease-button' )
58
+ . click ( )
59
+ expectFontSize ( expectedFontSize )
60
+ }
59
61
} )
60
62
61
63
it ( 'Resets the font size' , ( ) => {
62
- expect ( getCurrentFontSize ( ) ) . to . equal ( defaultFontSize )
63
- const clicks = 3
64
- cy . get ( 'button#font-size-decrease-button' ) . then ( ( $button ) => {
65
- for ( let i = 0 ; i < clicks ; i ++ ) {
66
- $button . trigger ( 'click' )
67
- }
68
- expect ( getCurrentFontSize ( ) ) . not . to . equal ( defaultFontSize )
69
- cy . get ( 'button#font-size-reset-button' )
64
+ expectFontSize ( defaultFontSize )
65
+ for ( let i = 0 ; i < 3 ; i ++ ) {
66
+ cy . get ( 'button#font-size-decrease-button' )
70
67
. click ( )
71
- . then ( ( ) => {
72
- expect ( getCurrentFontSize ( ) ) . to . equal ( defaultFontSize )
73
- } )
74
- } )
68
+ }
69
+ cy . get ( 'button#font-size-reset-button' )
70
+ . click ( )
71
+ expectFontSize ( defaultFontSize )
75
72
} )
76
73
77
74
it ( 'Sets the job theme' , ( ) => {
0 commit comments