Skip to content

Commit

Permalink
Merge pull request #17470 from ckeditor/ck/fix-editor-usage-tests-on-…
Browse files Browse the repository at this point in the history
…different-oses

Tests: OS and Browser agnostic mocking of env in editor usage data helper tests.
  • Loading branch information
Mati365 authored Nov 14, 2024
2 parents 09b6dcc + a7f19e5 commit 8e662a2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/ckeditor5-core/tests/editor/utils/editorusagedata.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe( 'getEditorUsageData()', () => {

for ( const [ flag, osName ] of os ) {
it( `should detect ${ osName } OS`, async () => {
sinon.stub( env, flag ).value( true );
mockFlag( flag );

editor = await ClassicTestEditor.create( domElement, {} );

Expand All @@ -201,6 +201,12 @@ describe( 'getEditorUsageData()', () => {
} );
} );
}

function mockFlag( mockFlag ) {
for ( const [ flag ] of os ) {
sinon.stub( env, flag ).value( flag === mockFlag );
}
}
} );

describe( 'browser', () => {
Expand All @@ -212,11 +218,7 @@ describe( 'getEditorUsageData()', () => {

for ( const [ flag, browser ] of browsers ) {
it( `should detect ${ browser } browser`, async () => {
sinon.stub( env, flag ).value( true );

if ( flag !== 'isBlink' ) {
sinon.stub( env, 'isBlink' ).value( false );
}
mockFlag( flag );

editor = await ClassicTestEditor.create( domElement, {} );

Expand All @@ -225,6 +227,12 @@ describe( 'getEditorUsageData()', () => {
} );
} );
}

function mockFlag( mockFlag ) {
for ( const [ flag ] of browsers ) {
sinon.stub( env, flag ).value( flag === mockFlag );
}
}
} );
} );

Expand Down

0 comments on commit 8e662a2

Please sign in to comment.