Skip to content

Commit 04ba5ce

Browse files
util: use util indices
1 parent 0cdb352 commit 04ba5ce

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/Deputy.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ import DeputyStorage from './DeputyStorage';
33
import DeputyCommunications from './DeputyCommunications';
44
import DeputySession from './session/DeputySession';
55
import DeputyCasePage from './wiki/DeputyCasePage';
6-
import normalizeTitle from './wiki/util/normalizeTitle';
76
import DeputyDispatch from './api/DeputyDispatch';
8-
import sectionHeadingName from './wiki/util/sectionHeadingName';
97
import ContributionSurveyRow from './models/ContributionSurveyRow';
10-
import getPageContent from './wiki/util/getPageContent';
11-
import cloneRegex from './util/cloneRegex';
128
import { DeputyPreferences } from './DeputyPreferences';
139
import performHacks from './wiki/util/performHacks';
1410
import DeputyCase from './wiki/DeputyCase';
@@ -26,7 +22,8 @@ import UserConfiguration from './config/UserConfiguration';
2622
import { attachConfigurationDialogPortletLink } from './ui/config/ConfigurationDialog';
2723
import WikiConfiguration from './config/WikiConfiguration';
2824
import Recents from './wiki/Recents';
29-
import msgEval from './wiki/util/msgEval';
25+
import util from './util';
26+
import wikiUtil from './wiki/util';
3027

3128
/**
3229
* The main class for Deputy. Entry point for execution.
@@ -52,13 +49,8 @@ class Deputy {
5249
readonly models = {
5350
ContributionSurveyRow: ContributionSurveyRow
5451
};
55-
readonly util = {
56-
cloneRegex: cloneRegex,
57-
getPageContent: getPageContent,
58-
normalizeTitle: normalizeTitle,
59-
sectionHeadingName: sectionHeadingName,
60-
msgEval: msgEval
61-
};
52+
readonly util = util;
53+
readonly wikiUtil = wikiUtil;
6254
readonly modules = {
6355
CopiedTemplateEditor: CopiedTemplateEditor,
6456
InfringementAssistant: InfringementAssistant

tests/unit/browser/UtilityUnitTests.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import '../../../src/types';
22
import 'types-mediawiki';
33
import BrowserHelper from '../../util/BrowserHelper';
44

5-
describe( 'Utility (on-browser) function tests', () => {
5+
describe( 'wikiUtility (on-browser) function tests', () => {
66

77
let page: BrowserHelper;
88

@@ -21,7 +21,7 @@ describe( 'Utility (on-browser) function tests', () => {
2121
// Default test
2222
expect(
2323
page.evaluate( () => {
24-
return { ...window.deputy.util.normalizeTitle() };
24+
return { ...window.deputy.wikiUtil.normalizeTitle() };
2525
} )
2626
).resolves.toEqual( {
2727
fragment: null, namespace: 4, title: 'Sandbox'
@@ -30,7 +30,7 @@ describe( 'Utility (on-browser) function tests', () => {
3030
// String parse test (mainspace)
3131
expect(
3232
page.evaluate( () => {
33-
return { ...window.deputy.util.normalizeTitle(
33+
return { ...window.deputy.wikiUtil.normalizeTitle(
3434
'Main Page'
3535
) };
3636
} )
@@ -41,7 +41,7 @@ describe( 'Utility (on-browser) function tests', () => {
4141
// String parse test (project space)
4242
expect(
4343
page.evaluate( () => {
44-
return { ...window.deputy.util.normalizeTitle(
44+
return { ...window.deputy.wikiUtil.normalizeTitle(
4545
'Wikipedia:Contributor copyright investigations'
4646
) };
4747
} )
@@ -52,7 +52,7 @@ describe( 'Utility (on-browser) function tests', () => {
5252
// String parse test (subpage)
5353
expect(
5454
page.evaluate( () => {
55-
return { ...window.deputy.util.normalizeTitle(
55+
return { ...window.deputy.wikiUtil.normalizeTitle(
5656
'Wikipedia:Contributor copyright investigations/Example'
5757
) };
5858
} )
@@ -63,7 +63,7 @@ describe( 'Utility (on-browser) function tests', () => {
6363
// String parse test (fragment)
6464
expect(
6565
page.evaluate( () => {
66-
return { ...window.deputy.util.normalizeTitle(
66+
return { ...window.deputy.wikiUtil.normalizeTitle(
6767
'Wikipedia:Contributor copyright investigations#Requests'
6868
) };
6969
} )
@@ -74,7 +74,7 @@ describe( 'Utility (on-browser) function tests', () => {
7474
// mw.Title test
7575
expect(
7676
page.evaluate( () => {
77-
return { ...window.deputy.util.normalizeTitle(
77+
return { ...window.deputy.wikiUtil.normalizeTitle(
7878
new mw.Title( 'Main Page' )
7979
) };
8080
} )

0 commit comments

Comments
 (0)