musora-content-services 1.0.192 → 1.0.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.194](https://github.com/railroadmedia/musora-content-services/compare/v1.0.193...v1.0.194) (2024-11-29)
6
+
7
+ ### [1.0.193](https://github.com/railroadmedia/musora-content-services/compare/v1.0.192...v1.0.193) (2024-11-28)
8
+
5
9
  ### [1.0.192](https://github.com/railroadmedia/musora-content-services/compare/v1.0.191...v1.0.192) (2024-11-28)
6
10
 
7
11
  ### [1.0.191](https://github.com/railroadmedia/musora-content-services/compare/v1.0.190...v1.0.191) (2024-11-28)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "1.0.192",
3
+ "version": "1.0.194",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -632,7 +632,7 @@ async function handleCustomFetchAll(brand, type, {
632
632
  } = {}) {
633
633
  if (type === 'challenge') {
634
634
  if (groupBy === 'completed') {
635
- const completedIds = fetchCompletedChallenges(brand, page, limit);
635
+ const completedIds = await fetchCompletedChallenges(brand, page, limit);
636
636
  return fetchAll(brand, type,
637
637
  {
638
638
  page,
@@ -641,13 +641,13 @@ async function handleCustomFetchAll(brand, type, {
641
641
  sort,
642
642
  includedFields,
643
643
  groupBy: '',
644
- completedIds,
644
+ progressIds: completedIds,
645
645
  useDefaultFields,
646
646
  customFields,
647
647
  progress
648
648
  });
649
649
  } else if (groupBy === 'owned') {
650
- const ownedIds = fetchOwnedChallenges(brand, page, limit);
650
+ const ownedIds = await fetchOwnedChallenges(brand, page, limit);
651
651
  return fetchAll(brand, type,
652
652
  {
653
653
  page,
@@ -656,7 +656,7 @@ async function handleCustomFetchAll(brand, type, {
656
656
  sort,
657
657
  includedFields,
658
658
  groupBy: '',
659
- ownedIds,
659
+ progressIds: ownedIds,
660
660
  useDefaultFields,
661
661
  customFields,
662
662
  progress
@@ -1,4 +1,6 @@
1
1
  import {getFieldsForContentType} from "../src/contentTypeConfig";
2
+ const railContentModule = require('../src/services/railcontent.js')
3
+
2
4
  import {
3
5
  fetchAssignments,
4
6
  fetchCommentModContentData,
@@ -8,6 +10,7 @@ import {
8
10
  import {log} from './log.js';
9
11
  import {initializeTestService} from "./initializeTests";
10
12
  import {dataContext} from "../src/services/contentProgress";
13
+ import {fetchOwnedChallenges} from "../src";
11
14
 
12
15
  const {
13
16
  fetchSongById,
@@ -266,14 +269,21 @@ describe('Sanity Queries', function () {
266
269
  const response = await fetchAll('drumeo', 'challenge', {groupBy:'difficulty_string'});
267
270
  expect(response.entity[0].name).toBeDefined();
268
271
  expect(response.entity[0].lessons).toBeDefined();
269
- expect(response.entity[0].lessons.length).toBeGreaterThan(0)
272
+ expect(response.entity[0].lessons.length).toBeGreaterThan(0);
270
273
  });
271
274
 
272
- test('fetchAllChallengesByDifficulty', async () => {
273
- const response = await fetchAll('drumeo', 'challenge', {groupBy:'difficulty_string'});
274
- expect(response.entity[0].name).toBeDefined();
275
- expect(response.entity[0].lessons).toBeDefined();
276
- expect(response.entity[0].lessons.length).toBeGreaterThan(0)
275
+ test('fetchAllChallengesByCompleted', async () => {
276
+ var mock = jest.spyOn(railContentModule, 'fetchCompletedChallenges');
277
+ mock.mockImplementation(() => [402204]);
278
+ const response = await fetchAll('drumeo', 'challenge', {groupBy:'completed'});
279
+ expect(response.entity.length).toBe(1);
280
+ });
281
+
282
+ test('fetchAllChallengesByOwned', async () => {
283
+ var mock = jest.spyOn(railContentModule, 'fetchOwnedChallenges');
284
+ mock.mockImplementation(() => [402204]);
285
+ const response = await fetchAll('drumeo', 'challenge', {groupBy:'owned'});
286
+ expect(response.entity.length).toBe(1);
277
287
  });
278
288
 
279
289
  test('fetchAll-CustomFields', async () => {