Skip to content

Commit 5f3fdaa

Browse files
committed
Merge branch 'master' into feature-inspection-dialog-dismissal-AD-571
2 parents aeb5cae + 56bf15f commit 5f3fdaa

File tree

16 files changed

+52
-33
lines changed

16 files changed

+52
-33
lines changed

src/data/actions/learningResourceActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function loadCourseReadingListsSuggestions(keyword) {
124124
}
125125

126126
const matchingCourseCodeFirst = a => {
127-
if (!!keyword && a?.name?.toUpperCase().substring(0, keyword.length) === keyword.toUpperCase()) {
127+
if (!!keyword && a?.name?.toUpperCase().substring(0, keyword.length) === keyword?.toUpperCase()) {
128128
return 1;
129129
}
130130
const firstFourCharacters = keyword?.toUpperCase().substring(0, 4);

src/data/mock/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import dlor_series_view from './data/records/dlor/dlor_series_view';
6363
import dlor_series_view_nodescription from './data/records/dlor/dlor_series_view_nodescription';
6464
import { dlor_demographics_report } from './data/dlorDemographics';
6565
import { dlor_favourites_report } from './data/dlorFavourites';
66-
import dlor_statistics from './data/records/dlor/dlor_statistics';
66+
import dlor_statistics from './data/records/dlor/dlor_statistics';
6767
import { drupalArticles } from './data/drupalArticles';
6868
import {
6969
journalSearchFavourites,
@@ -1031,7 +1031,7 @@ mock.onGet('exams/course/FREN1010/summary')
10311031
...examSearch_DENT80,
10321032
papers: [
10331033
...examSearch_DENT80.papers.filter(course =>
1034-
course.some(s => s.some(p => p.courseCode.toLowerCase() === 'dent1050')),
1034+
course.some(s => s.some(p => p?.courseCode?.toUpperCase() === 'DENT1050')),
10351035
),
10361036
],
10371037
},

src/helpers/general.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,12 @@ export const StyledTertiaryButton = styled(Button)(({ theme }) => ({
264264
display: 'none',
265265
},
266266
}));
267+
268+
// gets the File Type of a url eg PDF, as uppercase
269+
export const standardisedExtension = url => {
270+
if (!url || !(typeof url === 'string' || url instanceof String)) {
271+
return '';
272+
}
273+
const dotPosition = url?.lastIndexOf('.');
274+
return dotPosition > -1 ? url.substring(dotPosition + 1).toUpperCase() : '';
275+
};

src/helpers/general.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
stripHtml,
88
unescapeString,
99
standardText,
10+
standardisedExtension,
1011
} from './general';
1112

1213
describe('general helpers', () => {
@@ -106,4 +107,14 @@ describe('general helpers', () => {
106107
lineHeight: '1.6',
107108
});
108109
});
110+
111+
it('extracts extension', () => {
112+
expect(standardisedExtension('http://example.com/something.jpg')).toEqual('JPG');
113+
expect(standardisedExtension('.jpg')).toEqual('JPG'); // first char
114+
expect(standardisedExtension('http://example.com/something.')).toEqual(''); // last char
115+
expect(standardisedExtension('no_dot_at_all')).toEqual(''); // not a url
116+
expect(standardisedExtension(null)).toEqual(''); // invalid url
117+
expect(standardisedExtension(1)).toEqual(''); // invalid url
118+
expect(standardisedExtension(false)).toEqual(''); // invalid url
119+
});
109120
});

src/modules/HomePage/publicComponents/UtilityBar/Locations.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,11 @@ export const ariaLabelForLocation = location => {
287287
locationType = 'operating hours today';
288288
}
289289

290+
const libraryNameTemp = String(libraryName);
291+
const firstChar = libraryNameTemp?.charAt(0);
292+
const otherChar = libraryNameTemp?.slice(1);
290293
const capitaliseLibraryName =
291-
String(libraryName)
292-
.charAt(0)
293-
.toUpperCase() + String(libraryName).slice(1);
294+
libraryNameTemp.length > 0 ? firstChar.toUpperCase() + otherChar : /* istanbul ignore next */ '';
294295
let response = `${capitaliseLibraryName} ${locationType} is open ${openingHours}.`;
295296

296297
const busynessLabels = {

src/modules/Pages/Admin/Alerts/List/AlertSplitButton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export const AlertSplitButton = ({
6363
<ButtonGroup variant="contained" color="primary" ref={anchorRef} aria-label="split button">
6464
<StyledPrimaryButton
6565
children={mainButtonLabel}
66-
data-testid={`alert-list-item-${mainButtonLabel.toLowerCase()}-${alertId}`}
67-
id={`alert-list-item-${mainButtonLabel.toLowerCase()}-${alertId}`}
66+
data-testid={`alert-list-item-${mainButtonLabel?.toLowerCase()}-${alertId}`}
67+
id={`alert-list-item-${mainButtonLabel?.toLowerCase()}-${alertId}`}
6868
onClick={() =>
6969
mainButtonLabel === 'Edit' ? navigateToEditForm(alertId) : navigateToView(alertId)
7070
}

src/modules/Pages/Admin/Alerts/List/AlertsListAsTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const AlertsListAsTable = ({
139139
setPage(0);
140140
};
141141

142-
const tableType = headertag.replace(' alerts', '').toLowerCase();
142+
const tableType = headertag?.replace(' alerts', '').toLowerCase();
143143

144144
const headerCountIndicator = '[N] alert[s]'.replace('[N]', rows.length).replace('[s]', rows.length > 1 ? 's' : '');
145145

src/modules/Pages/Admin/TestTag/SharedComponents/AssetTypeSelector/AssetTypeSelector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const AssetTypeSelector = ({
112112
const filtered = filterOptions(options, params);
113113
canAddNew &&
114114
filtered.push({
115-
asset_type_name: locale.addNewLabel.toUpperCase(),
115+
asset_type_name: locale?.addNewLabel?.toUpperCase(),
116116
asset_type_id: ADD_NEW_ID,
117117
});
118118

src/modules/Pages/Admin/TestTag/SharedComponents/TestTagHeader/TestTagHeader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const TestTagHeader = (
6464
Dashboard
6565
</Link>
6666
{breadcrumbs.map((breadcrumb, index) => {
67-
const normalisedTitle = breadcrumb.title.replace(/ /g, '-').toLowerCase();
67+
const normalisedTitle = breadcrumb?.title?.replace(/ /g, '-').toLowerCase();
6868
return breadcrumb.link ? (
6969
<Link
7070
color="inherit"

src/modules/Pages/Admin/TestTag/helpers/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const capitaliseLeadingChar = text =>
2-
text.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, match => match.toUpperCase());
2+
text?.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, match => match?.toUpperCase());
33

44
export const isEmptyStr = str =>
55
str === null || str === undefined || (typeof str === 'string' && !!!str.trim()) || typeof str !== 'string';

0 commit comments

Comments
 (0)