mediawiki-extensions-Popups/tests/node-qunit/userSettings.test.js
Ed Sanders 883c8c1aca build: Update eslint-config-wikimedia to 0.22.1
Change-Id: I055517998ed06fccdf50ec31251ea6aa9040abb5
2022-02-28 13:18:24 +00:00

52 lines
1.4 KiB
JavaScript

import { createStubMap } from './stubs';
import createUserSettings from '../../src/userSettings';
QUnit.module( 'ext.popups/userSettings', {
beforeEach() {
this.storage = createStubMap();
this.userSettings = createUserSettings( this.storage );
}
} );
QUnit.test( '#isPagePreviewsEnabled should return false if Page Previews have been disabled', function ( assert ) {
this.userSettings.storePagePreviewsEnabled( false );
assert.false(
this.userSettings.isPagePreviewsEnabled(),
'The user has disabled Page Previews.'
);
// ---
this.userSettings.storePagePreviewsEnabled( true );
assert.true(
this.userSettings.isPagePreviewsEnabled(),
'#isPagePreviewsEnabled should return true if Page Previews have been enabled'
);
} );
QUnit.test( '#isReferencePreviewsEnabled', function ( assert ) {
assert.strictEqual(
this.storage.get( 'mwe-popups-referencePreviews-enabled' ),
null,
'Precondition: storage is empty.'
);
assert.true(
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.'
);
assert.false(
this.userSettings.isReferencePreviewsEnabled(),
'#isReferencePreviewsEnabled is now false.'
);
} );