Skip to content

Commit 6ddd3e8

Browse files
committed
Added some previously omitted test files.
1 parent 76cdcd6 commit 6ddd3e8

File tree

4 files changed

+201
-3
lines changed

4 files changed

+201
-3
lines changed

src/components/Organisations/SearchOrganisationRecords.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@
160160

161161
<script>
162162
163-
import TagChips from "@/components/Organisations/TagChips.vue";
164163
import RecordStatus from "@/components/Records/Shared/RecordStatus.vue";
164+
import TagChips from "@/components/Records/Shared/TagChips.vue";
165165
import recordsCardUtils from "@/utils/recordsCardUtils";
166166
import stringUtils from "@/utils/stringUtils";
167167
@@ -211,8 +211,8 @@ export default {
211211
downloadResults() {
212212
var MIME_TYPE = "text/csv";
213213
let data = ["name,abbreviation,URL\n"];
214-
this.getFairSharingRecords.forEach((record) => {
215-
data.push(`${record.name},${record.abbreviation || 'n/a'},https://fairsharing.org/${record.id}\n`);
214+
this.organisationLinks.forEach((link) => {
215+
data.push(`${link.fairsharingRecord.name},${link.fairsharingRecord.abbreviation || 'n/a'},https://fairsharing.org/${link.fairsharingRecord.id}\n`);
216216
})
217217
var blob = new Blob(data, {type: MIME_TYPE});
218218
window.location.href = window.URL.createObjectURL(blob);
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import {createLocalVue, shallowMount} from "@vue/test-utils";
2+
import Vuetify from "vuetify"
3+
import Vuex from "vuex";
4+
5+
import SearchOrganisationRecords from "@/components/Organisations/SearchOrganisationRecords.vue";
6+
7+
const localVue = createLocalVue();
8+
localVue.use(Vuex);
9+
10+
const vuetify = new Vuetify();
11+
12+
let organisation = {
13+
id: 1,
14+
name: "4DN Data Coordination and Integration Center",
15+
alternativeNames: [],
16+
homepage: "http://dcic.4dnucleome.org/",
17+
rorLink: "https://roro.roror.ror",
18+
types: [
19+
"Consortium"
20+
],
21+
urlForLogo: "/logo12345678",
22+
childOrganisations: [],
23+
parentOrganisations: [],
24+
organisationLinks: [
25+
{
26+
id: 6057,
27+
isLead: true,
28+
relation: "maintains",
29+
fairsharingRecord: {
30+
id: 872,
31+
name: "Pairs file format",
32+
abbreviation: ".pairs",
33+
type: "model_and_format",
34+
registry: "Standard",
35+
status: "ready"
36+
},
37+
"grant": null
38+
}
39+
],
40+
users: [],
41+
countries: []
42+
}
43+
44+
describe("SearchOrganisationRecords.vue", function(){
45+
let wrapper;
46+
47+
beforeEach(() => {
48+
wrapper = shallowMount(SearchOrganisationRecords, {
49+
localVue,
50+
vuetify,
51+
propsData: { organisation: organisation },
52+
stubs: ['router-link', 'router-view']
53+
})
54+
});
55+
56+
it("can be instantiated", () => {
57+
expect(wrapper.vm.$options.name).toMatch("SearchOrganisationRecords");
58+
});
59+
60+
it('gets abbreviations', () => {
61+
let record = {
62+
name: 'name'
63+
};
64+
expect(wrapper.vm.getAbbr(record)).toBe('');
65+
record.abbreviation = 'n';
66+
expect(wrapper.vm.getAbbr(record)).toEqual('(n)');
67+
});
68+
69+
it('reformats links', () => {
70+
let before = [
71+
{
72+
isLead: true,
73+
relation: true,
74+
fairsharingRecord: {
75+
name: 'test'
76+
}
77+
}
78+
]
79+
let after = [
80+
{
81+
isLead: true,
82+
relation: true,
83+
name: 'test'
84+
}
85+
]
86+
expect(wrapper.vm.reformatLinks(before)).toStrictEqual(after);
87+
});
88+
89+
});
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import {createLocalVue, shallowMount} from "@vue/test-utils";
2+
import Vuetify from "vuetify"
3+
4+
import TagChips from "@/components/Records/Shared/TagChips.vue"
5+
6+
let $route = {
7+
name: "search",
8+
query: {}
9+
};
10+
11+
const $router = {
12+
push: jest.fn(),
13+
};
14+
15+
describe("TagChips.vue", function () {
16+
let wrapper;
17+
const vuetify = new Vuetify();
18+
const localVue = createLocalVue();
19+
20+
beforeEach(() => {
21+
wrapper = shallowMount(TagChips, {
22+
localVue,
23+
vuetify,
24+
propsData: {
25+
record: {
26+
name: 'test record',
27+
subjects: [
28+
{
29+
label: 'first chip',
30+
active: false
31+
}
32+
],
33+
domains: [
34+
{
35+
label: 'second chip',
36+
active: false
37+
}
38+
],
39+
taxonomies: [
40+
{
41+
label: 'third chip',
42+
active: false
43+
},
44+
{
45+
label: 'fourth chip',
46+
active: false
47+
},
48+
{
49+
label: 'fifth chip',
50+
active: false
51+
},
52+
{
53+
label: 'sixth chip',
54+
active: false
55+
},
56+
{
57+
label: 'seventh chip',
58+
active: false
59+
},
60+
{
61+
label: 'eighth chip',
62+
active: false
63+
},
64+
{
65+
label: 'ninth chip',
66+
active: false
67+
}
68+
],
69+
user_defined_tags: [
70+
{
71+
label: 'a tag'
72+
}
73+
]
74+
}
75+
/*
76+
type: 'domains',
77+
chips: [
78+
{
79+
label: 'first chip',
80+
active: false
81+
}
82+
]
83+
*/
84+
},
85+
mocks: {$route, $router}
86+
});
87+
});
88+
89+
it("can be instantiated", () => {
90+
expect(wrapper.vm.$options.name).toMatch("TagChips");
91+
});
92+
93+
it("getChipColor", () => {
94+
let chip = {type: 'subjects'};
95+
expect(wrapper.vm.getChipColor(chip)).toEqual('subject_color');
96+
chip = {type: 'domains'};
97+
expect(wrapper.vm.getChipColor(chip)).toEqual('domain_color');
98+
chip = {type: 'taxonomies'};
99+
expect(wrapper.vm.getChipColor(chip)).toEqual('taxonomic_color');
100+
chip = {type: 'userDefinedTags'};
101+
expect(wrapper.vm.getChipColor(chip)).toEqual('tags_color');
102+
});
103+
104+
it("capitalises words properly", () => {
105+
expect(wrapper.vm.capitaliseText('this that', 'taxonomy')).toEqual('This that');
106+
expect(wrapper.vm.capitaliseText('this that', 'other')).toEqual('This That');
107+
});
108+
109+
});

0 commit comments

Comments
 (0)