Clean up code
This commit is contained in:
parent
09b19b9d22
commit
7da98d9ae7
|
|
@ -28,8 +28,9 @@
|
|||
computed: {
|
||||
contentBlocks() {
|
||||
return this.contents.map(contentBlock => {
|
||||
const contents = contentBlock.value ? [...contentBlock.value] : [];
|
||||
return Object.assign({}, contentBlock, {
|
||||
contents: [...contentBlock.value],
|
||||
contents,
|
||||
indent: true,
|
||||
bookmarks: this.parent.bookmarks,
|
||||
notes: this.parent.notes,
|
||||
|
|
|
|||
|
|
@ -6,18 +6,30 @@ export default {
|
|||
const query = ME_QUERY;
|
||||
if (schoolClass) {
|
||||
this.$log.debug('updating school class', schoolClass);
|
||||
const data = store.readQuery({query});
|
||||
if (data) {
|
||||
data.me.schoolClasses.edges = [
|
||||
...data.me.schoolClasses.edges,
|
||||
const {me} = store.readQuery({query});
|
||||
if (me) {
|
||||
let edges = [
|
||||
...me.schoolClasses.edges,
|
||||
{
|
||||
node: schoolClass,
|
||||
__typename: 'SchoolClassNodeEdge'
|
||||
}
|
||||
];
|
||||
data.me.selectedClass = {
|
||||
// me.schoolClasses.edges
|
||||
const selectedClass = {
|
||||
id: schoolClass.id,
|
||||
__typename: 'SchoolClassNode'
|
||||
};
|
||||
//me.selectedClass
|
||||
const data = {
|
||||
me: {
|
||||
...me,
|
||||
schoolClasses: {
|
||||
...me.schoolClasses,
|
||||
edges
|
||||
},
|
||||
selectedClass
|
||||
}
|
||||
};
|
||||
store.writeQuery({query, data});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {createLocalVue, mount} from '@vue/test-utils'
|
||||
import { createMockClient } from 'mock-apollo-client'
|
||||
import {createLocalVue, mount} from '@vue/test-utils';
|
||||
import { createMockClient } from 'mock-apollo-client';
|
||||
|
||||
import SIDEBAR from '@/graphql/gql/local/sidebar.gql';
|
||||
import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
|
||||
|
|
@ -8,7 +8,7 @@ import MY_SCHOOL_CLASS_QUERY from '@/graphql/gql/queries/mySchoolClass.gql';
|
|||
import DELETE_MODULE_NODES from '@/graphql/gql/local/mutations/deleteModuleNodes.gql';
|
||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
||||
|
||||
import VueApollo from 'vue-apollo'
|
||||
import VueApollo from 'vue-apollo';
|
||||
import ClassSelectionWidget from '@/components/school-class/ClassSelectionWidget';
|
||||
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ const meQueryResponse = {
|
|||
onboardingVisited: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const mySchoolClassResponse = {
|
||||
data: {}
|
||||
|
|
@ -127,7 +127,7 @@ describe('ClassSelectionWidget.vue', () => {
|
|||
deleteModulesHandler: jest.fn().mockResolvedValueOnce(deleteModulesResponse),
|
||||
mySchoolClassHandler: jest.fn().mockResolvedValueOnce(mySchoolClassResponse),
|
||||
moduleDetailHandler: jest.fn().mockResolvedValueOnce(moduleDetailResponse),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const createComponent = () => {
|
||||
|
|
@ -159,14 +159,14 @@ describe('ClassSelectionWidget.vue', () => {
|
|||
|
||||
wrapper.vm.me.schoolClass = schoolClasses;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
it('should delete the modules cache and query the current module on a class change', async () => {
|
||||
|
||||
createComponent();
|
||||
|
||||
wrapper.vm.me.selectedClass = {id: 'abcd123'}
|
||||
wrapper.vm.me.selectedClass = {id: 'abcd123'};
|
||||
wrapper.vm.updateSelectedClassAndHidePopover(schoolClasses[1]);
|
||||
|
||||
expect(requestHandlers.updateSettingsHandler).toHaveBeenCalledWith({
|
||||
|
|
@ -186,10 +186,10 @@ describe('ClassSelectionWidget.vue', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.destroy()
|
||||
mockClient = null
|
||||
apolloProvider = null
|
||||
})
|
||||
wrapper.destroy();
|
||||
mockClient = null;
|
||||
apolloProvider = null;
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { shallowMount, createLocalVue } from '@vue/test-utils'
|
||||
import ContentBlock from '@/components/ContentBlock'
|
||||
import Vuex from 'vuex'
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import ContentBlock from '@/components/ContentBlock';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
const localVue = createLocalVue()
|
||||
const localVue = createLocalVue();
|
||||
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Vuex);
|
||||
|
||||
describe('ContentBlock.vue', () => {
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ describe('ContentBlock.vue', () => {
|
|||
state: {},
|
||||
getters,
|
||||
actions: {}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should update index if content list has minimal length', () => {
|
||||
const props = {
|
||||
|
|
@ -237,4 +237,4 @@ describe('ContentBlock.vue', () => {
|
|||
expect(contents3).toEqual(contents);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { shallowMount } from '@vue/test-utils'
|
||||
import ModuleNavigation from '@/components/modules/ModuleNavigation'
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import ModuleNavigation from '@/components/modules/ModuleNavigation';
|
||||
|
||||
describe('ModuleNavigation.vue', () => {
|
||||
it('should flatten an array', () => {
|
||||
|
|
@ -11,7 +11,7 @@ describe('ModuleNavigation.vue', () => {
|
|||
propsData: props
|
||||
});
|
||||
|
||||
let arrayToFlatten = [[1], [2, 3], [4, 5, 6], [7]]
|
||||
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]);
|
||||
});
|
||||
|
|
@ -28,7 +28,7 @@ describe('ModuleNavigation.vue', () => {
|
|||
let nodeData = {
|
||||
type: 'assignment',
|
||||
id: 1
|
||||
}
|
||||
};
|
||||
|
||||
let assignment = wrapper.vm.findAssignment(nodeData);
|
||||
expect(assignment).toEqual([nodeData]);
|
||||
|
|
@ -58,10 +58,10 @@ describe('ModuleNavigation.vue', () => {
|
|||
type: 'content_list_item',
|
||||
id: 1,
|
||||
value: assignments
|
||||
}
|
||||
};
|
||||
|
||||
let foundAssignments = wrapper.vm.findAssignment(nodeData);
|
||||
expect(foundAssignments).toEqual(assignments);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue