2018-05-08 19:48:17 +00:00
|
|
|
import { createStubMap } from './stubs';
|
2017-07-28 17:32:46 +00:00
|
|
|
import createUserSettings from '../../src/userSettings';
|
2017-02-28 17:08:38 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/userSettings', {
|
2018-03-14 22:04:59 +00:00
|
|
|
beforeEach() {
|
2017-02-28 17:08:38 +00:00
|
|
|
this.storage = createStubMap();
|
2018-05-08 19:48:17 +00:00
|
|
|
this.userSettings = createUserSettings( this.storage );
|
2017-02-28 17:08:38 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2021-03-31 08:51:54 +00:00
|
|
|
QUnit.test( '#isPagePreviewsEnabled should return false if Page Previews have been disabled', function ( assert ) {
|
|
|
|
this.userSettings.storePagePreviewsEnabled( false );
|
2017-02-28 17:08:38 +00:00
|
|
|
|
2022-02-09 15:09:19 +00:00
|
|
|
assert.false(
|
2021-03-31 08:51:54 +00:00
|
|
|
this.userSettings.isPagePreviewsEnabled(),
|
2018-05-08 19:48:17 +00:00
|
|
|
'The user has disabled Page Previews.'
|
|
|
|
);
|
2017-02-28 17:08:38 +00:00
|
|
|
|
|
|
|
// ---
|
|
|
|
|
2021-03-31 08:51:54 +00:00
|
|
|
this.userSettings.storePagePreviewsEnabled( true );
|
2017-02-28 17:08:38 +00:00
|
|
|
|
2022-02-09 15:09:19 +00:00
|
|
|
assert.true(
|
2021-03-31 08:51:54 +00:00
|
|
|
this.userSettings.isPagePreviewsEnabled(),
|
|
|
|
'#isPagePreviewsEnabled should return true if Page Previews have been enabled'
|
2017-02-28 17:08:38 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2021-03-31 13:04:15 +00:00
|
|
|
QUnit.test( '#isReferencePreviewsEnabled', function ( assert ) {
|
|
|
|
assert.strictEqual(
|
|
|
|
this.storage.get( 'mwe-popups-referencePreviews-enabled' ),
|
|
|
|
null,
|
|
|
|
'Precondition: storage is empty.'
|
|
|
|
);
|
2022-02-09 15:09:19 +00:00
|
|
|
assert.true(
|
2021-03-31 13:04:15 +00:00
|
|
|
this.userSettings.isReferencePreviewsEnabled(),
|
|
|
|
'#isReferencePreviewsEnabled should default to true.'
|
|
|
|
);
|
|
|
|
|
|
|
|
this.userSettings.storeReferencePreviewsEnabled( false );
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
this.storage.get( 'mwe-popups-referencePreviews-enabled' ),
|
|
|
|
'0',
|
|
|
|
'#storeReferencePreviewsEnabled changes the storage.'
|
|
|
|
);
|
2022-02-09 15:09:19 +00:00
|
|
|
assert.false(
|
2021-03-31 13:04:15 +00:00
|
|
|
this.userSettings.isReferencePreviewsEnabled(),
|
|
|
|
'#isReferencePreviewsEnabled is now false.'
|
|
|
|
);
|
|
|
|
} );
|