-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some previously omitted test files.
- Loading branch information
Showing
4 changed files
with
201 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
89 changes: 89 additions & 0 deletions
89
tests/unit/components/Organisations/SearchOrganisationRecords.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import {createLocalVue, shallowMount} from "@vue/test-utils"; | ||
import Vuetify from "vuetify" | ||
import Vuex from "vuex"; | ||
|
||
import SearchOrganisationRecords from "@/components/Organisations/SearchOrganisationRecords.vue"; | ||
|
||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
|
||
const vuetify = new Vuetify(); | ||
|
||
let organisation = { | ||
id: 1, | ||
name: "4DN Data Coordination and Integration Center", | ||
alternativeNames: [], | ||
homepage: "http://dcic.4dnucleome.org/", | ||
rorLink: "https://roro.roror.ror", | ||
types: [ | ||
"Consortium" | ||
], | ||
urlForLogo: "/logo12345678", | ||
childOrganisations: [], | ||
parentOrganisations: [], | ||
organisationLinks: [ | ||
{ | ||
id: 6057, | ||
isLead: true, | ||
relation: "maintains", | ||
fairsharingRecord: { | ||
id: 872, | ||
name: "Pairs file format", | ||
abbreviation: ".pairs", | ||
type: "model_and_format", | ||
registry: "Standard", | ||
status: "ready" | ||
}, | ||
"grant": null | ||
} | ||
], | ||
users: [], | ||
countries: [] | ||
} | ||
|
||
describe("SearchOrganisationRecords.vue", function(){ | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = shallowMount(SearchOrganisationRecords, { | ||
localVue, | ||
vuetify, | ||
propsData: { organisation: organisation }, | ||
stubs: ['router-link', 'router-view'] | ||
}) | ||
}); | ||
|
||
it("can be instantiated", () => { | ||
expect(wrapper.vm.$options.name).toMatch("SearchOrganisationRecords"); | ||
}); | ||
|
||
it('gets abbreviations', () => { | ||
let record = { | ||
name: 'name' | ||
}; | ||
expect(wrapper.vm.getAbbr(record)).toBe(''); | ||
record.abbreviation = 'n'; | ||
expect(wrapper.vm.getAbbr(record)).toEqual('(n)'); | ||
}); | ||
|
||
it('reformats links', () => { | ||
let before = [ | ||
{ | ||
isLead: true, | ||
relation: true, | ||
fairsharingRecord: { | ||
name: 'test' | ||
} | ||
} | ||
] | ||
let after = [ | ||
{ | ||
isLead: true, | ||
relation: true, | ||
name: 'test' | ||
} | ||
] | ||
expect(wrapper.vm.reformatLinks(before)).toStrictEqual(after); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import {createLocalVue, shallowMount} from "@vue/test-utils"; | ||
import Vuetify from "vuetify" | ||
|
||
import TagChips from "@/components/Records/Shared/TagChips.vue" | ||
|
||
let $route = { | ||
name: "search", | ||
query: {} | ||
}; | ||
|
||
const $router = { | ||
push: jest.fn(), | ||
}; | ||
|
||
describe("TagChips.vue", function () { | ||
let wrapper; | ||
const vuetify = new Vuetify(); | ||
const localVue = createLocalVue(); | ||
|
||
beforeEach(() => { | ||
wrapper = shallowMount(TagChips, { | ||
localVue, | ||
vuetify, | ||
propsData: { | ||
record: { | ||
name: 'test record', | ||
subjects: [ | ||
{ | ||
label: 'first chip', | ||
active: false | ||
} | ||
], | ||
domains: [ | ||
{ | ||
label: 'second chip', | ||
active: false | ||
} | ||
], | ||
taxonomies: [ | ||
{ | ||
label: 'third chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'fourth chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'fifth chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'sixth chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'seventh chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'eighth chip', | ||
active: false | ||
}, | ||
{ | ||
label: 'ninth chip', | ||
active: false | ||
} | ||
], | ||
user_defined_tags: [ | ||
{ | ||
label: 'a tag' | ||
} | ||
] | ||
} | ||
/* | ||
type: 'domains', | ||
chips: [ | ||
{ | ||
label: 'first chip', | ||
active: false | ||
} | ||
] | ||
*/ | ||
}, | ||
mocks: {$route, $router} | ||
}); | ||
}); | ||
|
||
it("can be instantiated", () => { | ||
expect(wrapper.vm.$options.name).toMatch("TagChips"); | ||
}); | ||
|
||
it("getChipColor", () => { | ||
let chip = {type: 'subjects'}; | ||
expect(wrapper.vm.getChipColor(chip)).toEqual('subject_color'); | ||
chip = {type: 'domains'}; | ||
expect(wrapper.vm.getChipColor(chip)).toEqual('domain_color'); | ||
chip = {type: 'taxonomies'}; | ||
expect(wrapper.vm.getChipColor(chip)).toEqual('taxonomic_color'); | ||
chip = {type: 'userDefinedTags'}; | ||
expect(wrapper.vm.getChipColor(chip)).toEqual('tags_color'); | ||
}); | ||
|
||
it("capitalises words properly", () => { | ||
expect(wrapper.vm.capitaliseText('this that', 'taxonomy')).toEqual('This that'); | ||
expect(wrapper.vm.capitaliseText('this that', 'other')).toEqual('This That'); | ||
}); | ||
|
||
}); |