Skip to content

Commit 0a0feb6

Browse files
committed
Make sure our JS dependencies reflect what we actually depend on.
1 parent d695e45 commit 0a0feb6

File tree

9 files changed

+101
-724
lines changed

9 files changed

+101
-724
lines changed

__mocks__/backbone.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

__mocks__/vue.js

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'underscore';
21
import Vue from 'vue';
32
import Vuetify from 'vuetify';
43
import { mount } from '@vue/test-utils';
@@ -18,19 +17,16 @@ function makeWrapper(kind) {
1817
}
1918

2019
describe('ContentNodeIcon', () => {
21-
it('should display the correct icon', () => {
22-
function test(kind) {
23-
let wrapper = makeWrapper(kind.value);
24-
expect(wrapper.find('.v-icon').text()).toContain(kind.icon);
25-
}
26-
let testIcons = [
27-
{ value: 'topic', icon: 'folder' },
28-
{ value: 'video', icon: 'ondemand_video' },
29-
{ value: 'audio', icon: 'music_note' },
30-
{ value: 'exercise', icon: 'assignment' },
31-
{ value: 'document', icon: 'class' },
32-
{ value: 'html5', icon: 'widgets' },
33-
];
34-
_.each(testIcons, test);
20+
const testIcons = [
21+
{ value: 'topic', icon: 'folder' },
22+
{ value: 'video', icon: 'ondemand_video' },
23+
{ value: 'audio', icon: 'music_note' },
24+
{ value: 'exercise', icon: 'assignment' },
25+
{ value: 'document', icon: 'class' },
26+
{ value: 'html5', icon: 'widgets' },
27+
];
28+
it.each(testIcons)('should display the correct icon $value', kind => {
29+
const wrapper = makeWrapper(kind.value);
30+
expect(wrapper.find('.v-icon').text()).toContain(kind.icon);
3531
});
3632
});

contentcuration/contentcuration/frontend/shared/views/__tests__/languageDropdown.spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'underscore';
21
import Vue from 'vue';
32
import Vuetify from 'vuetify';
43
import { mount } from '@vue/test-utils';
@@ -18,7 +17,7 @@ function makeWrapper() {
1817
});
1918
}
2019

21-
let testLanguages = _.first(LanguagesList, 10);
20+
const testLanguages = LanguagesList.slice(0, 10);
2221

2322
describe('languageDropdown', () => {
2423
let wrapper;
@@ -27,16 +26,13 @@ describe('languageDropdown', () => {
2726
formWrapper = makeWrapper();
2827
wrapper = formWrapper.find(LanguageDropdown);
2928
});
30-
it('updating the language should emit input event', () => {
29+
it.each(testLanguages)('updating language $id should emit input event', language => {
3130
expect(wrapper.emitted('input')).toBeFalsy();
32-
function test(language, i) {
33-
// It looks like v-autocomplete doesn't trigger correctly, so call
34-
// method directly until resolved
35-
wrapper.find('.v-autocomplete').vm.$emit('input', language.id);
36-
expect(wrapper.emitted('input')).toBeTruthy();
37-
expect(wrapper.emitted('input')[i][0]).toEqual(language.id);
38-
}
39-
_.each(testLanguages, test);
31+
// It looks like v-autocomplete doesn't trigger correctly, so call
32+
// method directly until resolved
33+
wrapper.find('.v-autocomplete').vm.$emit('input', language.id);
34+
expect(wrapper.emitted('input')).toBeTruthy();
35+
expect(wrapper.emitted('input')[0][0]).toEqual(language.id);
4036
});
4137
it('setting readonly should prevent any edits', () => {
4238
expect(wrapper.find('input[readonly]').exists()).toBe(false);

contentcuration/contentcuration/frontend/shared/views/__tests__/licenseDropdown.spec.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'underscore';
21
import Vue from 'vue';
32
import Vuetify from 'vuetify';
43
import { mount } from '@vue/test-utils';
@@ -19,7 +18,7 @@ function makeWrapper() {
1918
}
2019

2120
describe('licenseDropdown', () => {
22-
let specialPermissions = _.findWhere(LicensesList, { is_custom: true });
21+
const specialPermissions = LicensesList.find(l => l.is_custom);
2322
let wrapper;
2423
let formWrapper;
2524
beforeEach(() => {
@@ -28,27 +27,25 @@ describe('licenseDropdown', () => {
2827
});
2928

3029
describe('on load', () => {
31-
it('all license options should be an option to select', () => {
32-
_.each(LicensesList, license => {
33-
expect(wrapper.find('.v-list').text()).toContain(license.license_name);
34-
});
30+
it.each(LicensesList)('%s license option should be an option to select', license => {
31+
expect(wrapper.find('.v-list').text()).toContain(license.license_name);
3532
});
36-
it('should render a license when value is set to a license id', () => {
37-
function test(license) {
33+
it.each(LicensesList)(
34+
'should render license when value is set to a license id $id',
35+
license => {
3836
wrapper.setProps({ value: { license: license.id } });
3937
expect(wrapper.vm.$refs.license.value).toEqual(license.id);
4038
expect(wrapper.find('.v-textarea').exists()).toBe(license.is_custom);
4139
}
42-
_.each(LicensesList, test);
43-
});
44-
it('should render a license when value is set to a license name', () => {
45-
function test(license) {
40+
);
41+
it.each(LicensesList)(
42+
'should render license when value is set to a license name $name',
43+
license => {
4644
wrapper.setProps({ value: { license: license.license_name } });
4745
expect(wrapper.vm.$refs.license.value).toEqual(license.id);
4846
expect(wrapper.find('.v-textarea').exists()).toBe(license.is_custom);
4947
}
50-
_.each(LicensesList, test);
51-
});
48+
);
5249
it('should display licenseDescription prop', () => {
5350
wrapper.setProps({
5451
value: { license: specialPermissions.id, license_description: 'test description' },

contentcuration/contentcuration/frontend/shared/views/__tests__/visibilityDropdown.spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'underscore';
21
import { mount } from '@vue/test-utils';
32
import VisibilityDropdown from '../VisibilityDropdown.vue';
43
import TestForm from './TestForm.vue';
@@ -15,6 +14,8 @@ function makeWrapper() {
1514
});
1615
}
1716

17+
const RolesArray = Array.from(Roles);
18+
1819
describe('visibilityDropdown', () => {
1920
let wrapper;
2021
let formWrapper;
@@ -24,17 +25,12 @@ describe('visibilityDropdown', () => {
2425
});
2526

2627
describe('on load', () => {
27-
it('all visibility options should be an option to select', () => {
28-
Roles.forEach(role => {
29-
expect(wrapper.find('.v-list').text()).toContain(constantStrings.$tr(role));
30-
});
28+
it.each(RolesArray)('all visibility options should be an option to select', role => {
29+
expect(wrapper.find('.v-list').text()).toContain(constantStrings.$tr(role));
3130
});
32-
it('should render according to visibility prop', () => {
33-
function test(visibility) {
34-
wrapper.setProps({ value: visibility });
35-
expect(wrapper.vm.$refs.visibility.value).toEqual(visibility);
36-
}
37-
_.each(Roles, test);
31+
it.each(RolesArray)('should render according to visibility prop %s', visibility => {
32+
wrapper.setProps({ value: visibility });
33+
expect(wrapper.vm.$refs.visibility.value).toEqual(visibility);
3834
});
3935
});
4036
describe('props', () => {

0 commit comments

Comments
 (0)