Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4129620
syncUserSettings.test.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
syncUserSettings.test.js
View Options
import
syncUserSettings
from
'../../../src/changeListeners/syncUserSettings'
;
QUnit
.
module
(
'ext.popups/changeListeners/syncUserSettings'
,
{
beforeEach
()
{
this
.
userSettings
=
{
storePreviewTypeEnabled
:
this
.
sandbox
.
spy
()
};
this
.
changeListener
=
syncUserSettings
(
this
.
userSettings
);
}
}
);
QUnit
.
test
(
'it shouldn\'t update the storage if the enabled state hasn\'t changed'
,
function
(
assert
)
{
const
oldState
=
{
preview
:
{
enabled
:
{
page
:
true
}
}
},
newState
=
{
preview
:
{
enabled
:
{
page
:
true
}
}
};
this
.
changeListener
(
undefined
,
newState
);
this
.
changeListener
(
oldState
,
newState
);
assert
.
false
(
this
.
userSettings
.
storePreviewTypeEnabled
.
called
,
'The user setting is unchanged.'
);
}
);
QUnit
.
test
(
'it should update the storage if the enabled flag has changed'
,
function
(
assert
)
{
const
oldState
=
{
preview
:
{
enabled
:
{
page
:
true
}
}
},
newState
=
{
preview
:
{
enabled
:
{
page
:
false
}
}
};
this
.
changeListener
(
oldState
,
newState
);
assert
.
true
(
this
.
userSettings
.
storePreviewTypeEnabled
.
calledWith
(
'page'
,
false
),
'The user setting is disabled.'
);
}
);
QUnit
.
test
(
'it shouldn\'t update the storage if the reference preview state hasn\'t changed'
,
function
(
assert
)
{
const
oldState
=
{
preview
:
{
enabled
:
{
reference
:
true
}
}
},
newState
=
{
preview
:
{
enabled
:
{
reference
:
true
}
}
};
this
.
changeListener
(
undefined
,
newState
);
this
.
changeListener
(
oldState
,
newState
);
assert
.
false
(
this
.
userSettings
.
storePreviewTypeEnabled
.
called
,
'Reference previews are unchanged.'
);
}
);
QUnit
.
test
(
'it should update the storage if the reference preview state has changed'
,
function
(
assert
)
{
const
oldState
=
{
preview
:
{
enabled
:
{
reference
:
true
}
}
},
newState
=
{
preview
:
{
enabled
:
{
reference
:
false
}
}
};
this
.
changeListener
(
oldState
,
newState
);
assert
.
true
(
this
.
userSettings
.
storePreviewTypeEnabled
.
calledWith
(
'reference'
,
false
),
'Reference previews opt-out is stored.'
);
}
);
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, Aug 19, 10:00 (2 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bd/ee/96bb65e5e14c78bf3cdb8ed3a6b7
Default Alt Text
syncUserSettings.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment