musora-content-services 1.0.7 → 1.0.9

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.
@@ -0,0 +1,88 @@
1
+ const {
2
+ initializeSanityService,
3
+ fetchSongById,
4
+ fetchArtists,
5
+ fetchSongArtistCount,
6
+ fetchRelatedSongs,
7
+ fetchAllSongs,
8
+ fetchSongFilterOptions,
9
+ fetchSongCount,
10
+ fetchWorkouts,
11
+ fetchNewReleases,
12
+ fetchUpcomingEvents,
13
+ fetchByRailContentId,
14
+ fetchByRailContentIds,
15
+ fetchAll,
16
+ fetchAllFilterOptions,
17
+ fetchMethodNextLesson,
18
+ fetchMethodChildren,
19
+ fetchNextPreviousLesson,
20
+ fetchRelatedLessons,
21
+ fetchPackAll,
22
+ fetchPackChildren,
23
+ fetchLessonContent
24
+ } = require('../src/index.js');
25
+
26
+ describe('Sanity Queries', function () {
27
+ beforeEach(() => {
28
+ const config = {
29
+ token: process.env.SANITY_API_TOKEN,
30
+ projectId: process.env.SANITY_PROJECT_ID,
31
+ dataset: process.env.SANITY_DATASET,
32
+ useCachedAPI: process.env.SANITY_USE_CACHED_API || true,
33
+ version: '2021-06-07',
34
+ debug: process.env.DEBUG || false
35
+ };
36
+ initializeSanityService(config);
37
+ });
38
+
39
+ test('fetchSongById', async () => {
40
+ const id = 380094;
41
+ const response = await fetchSongById(id);
42
+ expect(response.railcontent_id).toBe(id);
43
+
44
+ });
45
+
46
+ test('fetchArtists', async () => {
47
+ const response = await fetchArtists('drumeo');
48
+ const artistNames = response.map((x) => x.name);
49
+ expect(artistNames).toContain("Arctic Monkeys");
50
+
51
+ });
52
+
53
+ test('fetchSongArtistCount', async () => {
54
+ const response = await fetchSongArtistCount('drumeo');
55
+ console.log(response);
56
+ expect(response).toBeGreaterThan(1000);
57
+ });
58
+
59
+ test('fetchByRailContentId', async () => {
60
+ const id = 380094;
61
+ const response = await fetchByRailContentId(id);
62
+ expect(response.railcontent_id).toBe(id);
63
+ });
64
+
65
+ test('fetchByRailContentIds', async () => {
66
+ const id = 380094;
67
+ const id2 = 402204;
68
+ const response = await fetchByRailContentIds([id, id2]);
69
+ const returnedIds = response.map((x) => x.railcontent_id);
70
+ expect(returnedIds).toContain(id);
71
+ expect(returnedIds).toContain(id2);
72
+ expect(returnedIds.length).toBe(2);
73
+
74
+ });
75
+
76
+ test('fetchLessonContent', async () => {
77
+ const id = 380094;
78
+ const response = await fetchLessonContent(id);
79
+ expect(response.railcontent_id).toBe(id);
80
+ });
81
+
82
+ // test('fetchRelatedLessons', async () => {
83
+ // const id = 380094;
84
+ // const response = await fetchRelatedLessons(id, 'singeo', 'song');
85
+ // console.log(response.related_lessons[0]);
86
+ // expect(response.related_lessons[0]).toBe(id);
87
+ // });
88
+ });