diff --git a/src/content-tags-drawer/tags-sidebar-controls/TagsSidebarHeader.jsx b/src/content-tags-drawer/tags-sidebar-controls/TagsSidebarHeader.jsx
index ea154574b0..9101d30f2f 100644
--- a/src/content-tags-drawer/tags-sidebar-controls/TagsSidebarHeader.jsx
+++ b/src/content-tags-drawer/tags-sidebar-controls/TagsSidebarHeader.jsx
@@ -15,7 +15,7 @@ const TagsSidebarHeader = () => {
const {
data: contentTagsCount,
isSuccess: isContentTagsCountLoaded,
- } = useContentTagsCount(contentId || '');
+ } = useContentTagsCount(contentId);
return (
)}
- { getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' && contentTagCount > 0 && (
+ { getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' && !!contentTagCount && (
)}
diff --git a/src/generic/data/api.test.js b/src/generic/data/api.test.js
index 96b6634d54..eeac9c65cd 100644
--- a/src/generic/data/api.test.js
+++ b/src/generic/data/api.test.js
@@ -86,8 +86,9 @@ describe('generic api calls', () => {
expect(contentTagsCountMock[contentId]).toEqual(15);
});
- it('should get null on empty pattern', async () => {
- const result = await getTagsCount('');
- expect(result).toEqual(null);
+ it('should throw an error if no pattern is provided', async () => {
+ const pattern = undefined;
+ expect(getTagsCount(pattern)).rejects.toThrow('contentPattern is required');
+ expect(axiosMock.history.get.length).toEqual(0);
});
});
diff --git a/src/generic/data/api.js b/src/generic/data/api.ts
similarity index 58%
rename from src/generic/data/api.js
rename to src/generic/data/api.ts
index 83fd561ff3..fbec8b55bf 100644
--- a/src/generic/data/api.js
+++ b/src/generic/data/api.ts
@@ -1,4 +1,3 @@
-// @ts-check
import { camelCaseObject, getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
@@ -6,16 +5,21 @@ import { convertObjectToSnakeCase } from '../../utils';
export const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;
export const getCreateOrRerunCourseUrl = () => new URL('course/', getApiBaseUrl()).href;
-export const getCourseRerunUrl = (courseId) => new URL(`/api/contentstore/v1/course_rerun/${courseId}`, getApiBaseUrl()).href;
+export const getCourseRerunUrl = (courseId: string) => new URL(
+ `/api/contentstore/v1/course_rerun/${courseId}`,
+ getApiBaseUrl(),
+).href;
export const getOrganizationsUrl = () => new URL('organizations', getApiBaseUrl()).href;
export const getClipboardUrl = () => `${getApiBaseUrl()}/api/content-staging/v1/clipboard/`;
-export const getTagsCountApiUrl = (contentPattern) => new URL(`api/content_tagging/v1/object_tag_counts/${contentPattern}/?count_implicit`, getApiBaseUrl()).href;
+export const getTagsCountApiUrl = (contentPattern: string) => new URL(
+ `api/content_tagging/v1/object_tag_counts/${contentPattern}/?count_implicit`,
+ getApiBaseUrl(),
+).href;
/**
* Get's organizations data. Returns list of organization names.
- * @returns {Promise}
*/
-export async function getOrganizations() {
+export async function getOrganizations(): Promise {
const { data } = await getAuthenticatedHttpClient().get(
getOrganizationsUrl(),
);
@@ -24,9 +28,8 @@ export async function getOrganizations() {
/**
* Get's course rerun data.
- * @returns {Promise