68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
import { shallowMount } from '@vue/test-utils';
|
|
import ModuleNavigation from '@/components/modules/ModuleNavigation';
|
|
|
|
describe('ModuleNavigation.vue', () => {
|
|
it('should flatten an array', () => {
|
|
const props = {
|
|
modules: [],
|
|
me: {}
|
|
};
|
|
const wrapper = shallowMount(ModuleNavigation, {
|
|
propsData: props
|
|
});
|
|
|
|
let arrayToFlatten = [[1], [2, 3], [4, 5, 6], [7]];
|
|
let flattenedArray = wrapper.vm.flattenArray(arrayToFlatten);
|
|
expect(flattenedArray).toEqual([1, 2, 3, 4, 5, 6, 7]);
|
|
});
|
|
|
|
it('should find top level assignment', () => {
|
|
const props = {
|
|
modules: [],
|
|
me: {}
|
|
};
|
|
const wrapper = shallowMount(ModuleNavigation, {
|
|
propsData: props
|
|
});
|
|
|
|
let nodeData = {
|
|
type: 'assignment',
|
|
id: 1
|
|
};
|
|
|
|
let assignment = wrapper.vm.findAssignment(nodeData);
|
|
expect(assignment).toEqual([nodeData]);
|
|
});
|
|
|
|
it('should find content list assignments', () => {
|
|
const props = {
|
|
modules: [],
|
|
me: {}
|
|
};
|
|
const wrapper = shallowMount(ModuleNavigation, {
|
|
propsData: props
|
|
});
|
|
|
|
let assignments = [
|
|
{
|
|
type: 'assignment',
|
|
id: 2
|
|
},
|
|
{
|
|
type: 'assignment',
|
|
id: 3
|
|
}
|
|
];
|
|
|
|
let nodeData = {
|
|
type: 'content_list_item',
|
|
id: 1,
|
|
value: assignments
|
|
};
|
|
|
|
let foundAssignments = wrapper.vm.findAssignment(nodeData);
|
|
expect(foundAssignments).toEqual(assignments);
|
|
});
|
|
|
|
});
|