style: fix linting issues met Prettier
This commit is contained in:
parent
db582ee46a
commit
09bf765e8c
1 changed files with 28 additions and 33 deletions
|
@ -1,13 +1,8 @@
|
||||||
import {describe, it, expect, vi} from 'vitest';
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
import {
|
import { LearningObjectMetadata, LearningPath } from '../../src/interfaces/learningPath';
|
||||||
LearningObjectMetadata, LearningPath,
|
import { fetchWithLogging } from '../../src/util/apiHelper';
|
||||||
} from "../../src/interfaces/learningPath";
|
import { getLearningObjectById, getLearningObjectsFromPath } from '../../src/services/learningObjects';
|
||||||
import {fetchWithLogging} from "../../src/util/apiHelper";
|
import { fetchLearningPaths } from '../../src/services/learningPaths';
|
||||||
import {
|
|
||||||
getLearningObjectById,
|
|
||||||
getLearningObjectsFromPath
|
|
||||||
} from "../../src/services/learningObjects";
|
|
||||||
import {fetchLearningPaths} from "../../src/services/learningPaths";
|
|
||||||
|
|
||||||
// Mock API functions
|
// Mock API functions
|
||||||
vi.mock('../../src/util/apiHelper', () => ({
|
vi.mock('../../src/util/apiHelper', () => ({
|
||||||
|
@ -18,7 +13,6 @@ vi.mock('../../src/services/learningPaths', () => ({
|
||||||
fetchLearningPaths: vi.fn(),
|
fetchLearningPaths: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
describe('getLearningObjectById', () => {
|
describe('getLearningObjectById', () => {
|
||||||
const hruid = 'test-object';
|
const hruid = 'test-object';
|
||||||
const language = 'en';
|
const language = 'en';
|
||||||
|
@ -33,12 +27,12 @@ describe('getLearningObjectById', () => {
|
||||||
estimated_time: 120,
|
estimated_time: 120,
|
||||||
available: true,
|
available: true,
|
||||||
teacher_exclusive: false,
|
teacher_exclusive: false,
|
||||||
educational_goals: [{source: 'source', id: 'id'}],
|
educational_goals: [{ source: 'source', id: 'id' }],
|
||||||
keywords: ['robotics'],
|
keywords: ['robotics'],
|
||||||
description: 'A test object',
|
description: 'A test object',
|
||||||
target_ages: [10, 12],
|
target_ages: [10, 12],
|
||||||
content_type: 'markdown',
|
content_type: 'markdown',
|
||||||
content_location: ''
|
content_location: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
it('✅ Should return a filtered learning object when API provides data', async () => {
|
it('✅ Should return a filtered learning object when API provides data', async () => {
|
||||||
|
@ -58,12 +52,12 @@ describe('getLearningObjectById', () => {
|
||||||
estimatedTime: 120,
|
estimatedTime: 120,
|
||||||
available: true,
|
available: true,
|
||||||
teacherExclusive: false,
|
teacherExclusive: false,
|
||||||
educationalGoals: [{source: 'source', id: 'id'}],
|
educationalGoals: [{ source: 'source', id: 'id' }],
|
||||||
keywords: ['robotics'],
|
keywords: ['robotics'],
|
||||||
description: 'A test object',
|
description: 'A test object',
|
||||||
targetAges: [10, 12],
|
targetAges: [10, 12],
|
||||||
contentType: 'markdown',
|
contentType: 'markdown',
|
||||||
contentLocation: ''
|
contentLocation: '',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,32 +68,33 @@ describe('getLearningObjectById', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('getLearningObjectsFromPath', () => {
|
describe('getLearningObjectsFromPath', () => {
|
||||||
const hruid = 'test-path';
|
const hruid = 'test-path';
|
||||||
const language = 'en';
|
const language = 'en';
|
||||||
|
|
||||||
it('✅ Should not give error or warning', async () => {
|
it('✅ Should not give error or warning', async () => {
|
||||||
const mockPathResponse: LearningPath[] = [{
|
const mockPathResponse: LearningPath[] = [
|
||||||
_id: 'path-1',
|
{
|
||||||
hruid,
|
_id: 'path-1',
|
||||||
language,
|
hruid,
|
||||||
title: 'Test Path',
|
language,
|
||||||
description: '',
|
title: 'Test Path',
|
||||||
num_nodes: 1,
|
description: '',
|
||||||
num_nodes_left: 0,
|
num_nodes: 1,
|
||||||
nodes: [],
|
num_nodes_left: 0,
|
||||||
keywords: '',
|
nodes: [],
|
||||||
target_ages: [],
|
keywords: '',
|
||||||
min_age: 10,
|
target_ages: [],
|
||||||
max_age: 12,
|
min_age: 10,
|
||||||
__order: 1,
|
max_age: 12,
|
||||||
}];
|
__order: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
vi.mocked(fetchLearningPaths).mockResolvedValueOnce({
|
vi.mocked(fetchLearningPaths).mockResolvedValueOnce({
|
||||||
success: true,
|
success: true,
|
||||||
source: 'Test Source',
|
source: 'Test Source',
|
||||||
data: mockPathResponse
|
data: mockPathResponse,
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await getLearningObjectsFromPath(hruid, language);
|
const result = await getLearningObjectsFromPath(hruid, language);
|
||||||
|
@ -107,7 +102,7 @@ describe('getLearningObjectsFromPath', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('⚠️ Should give a warning', async () => {
|
it('⚠️ Should give a warning', async () => {
|
||||||
vi.mocked(fetchLearningPaths).mockResolvedValueOnce({success: false, source: 'Test Source', data: []});
|
vi.mocked(fetchLearningPaths).mockResolvedValueOnce({ success: false, source: 'Test Source', data: [] });
|
||||||
|
|
||||||
const result = await getLearningObjectsFromPath(hruid, language);
|
const result = await getLearningObjectsFromPath(hruid, language);
|
||||||
expect(result).toEqual([]);
|
expect(result).toEqual([]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue