Commit 1585fffa authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

Fixing tests

parent 1cb5243d
......@@ -18,7 +18,7 @@ export default {
if (jobInfo.state === 'SUCCESS') {
return jobInfo.result
} else if (jobInfo.state === 'FAILURE') {
throw jobInfo.result
throw new Error(jobInfo.result)
} else if (jobInfo.state === 'PENDING') {
} else {
throw new Error(`Analysis Job has unknown state: ${jobInfo.state}`)
......
......@@ -13,35 +13,35 @@ describe('DataBox', () => {
it('renders 3 checkboxes for 3 elements in data', () => {
store.state.data = [
{dataType: 'numeric', description: ''},
{dataType: 'numeric', description: ''},
{dataType: 'numeric', description: ''}
{data_type: 'numeric', description: ''},
{data_type: 'numeric', description: ''},
{data_type: 'numeric', description: ''}
]
const Component = Vue.extend(DataBox)
const propsData = {dataType: 'numeric'}
const propsData = {dataType: 'numeric', header: ''}
const vm = new Component({propsData}).$mount()
expect(vm.$el.querySelectorAll('.data-item').length).toBe(3)
})
it('only renders checkboxes for data with correct type', () => {
store.state.data = [
{dataType: 'numeric', description: ''},
{dataType: 'categoric', description: ''},
{data_type: 'numeric', description: ''},
{data_type: 'categoric', description: ''},
]
const Component = Vue.extend(DataBox)
const propsData = {dataType: 'numeric'}
const propsData = {dataType: 'numeric', header: ''}
const vm = new Component({propsData}).$mount()
expect(vm.$el.querySelectorAll('.data-item').length).toBe(1)
})
it('checkboxes are linked to data', () => {
store.state.data = [
{dataType: 'numeric', description: 'A'},
{dataType: 'numeric', description: 'B'},
{data_type: 'numeric', description: '', data_id: 'A'},
{data_type: 'numeric', description: '', data_id: ''}
]
const Component = Vue.extend(DataBox)
const propsData = {dataType: 'numeric'}
const data = {checkedItems: ['A']}
const propsData = {dataType: 'numeric', header: ''}
const data = {selectedIDs: ['A']}
const vm = new Component({propsData, data}).$mount()
expect(vm.$el.querySelectorAll('.data-item').length).toBe(2)
expect(vm.$el.querySelector('#data-check-0').checked).toBeTruthy()
......
......@@ -20,9 +20,9 @@ describe('runAnalysis method', () => {
it('fails if unknown job state', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve(123))
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({state: 'FOO', result: ''}))
.and.returnValue(Promise.resolve({data: {state: 'FOO', result: ''}}))
runAnalysis({name: '', args: {}})
.then(done.fail)
.catch(done)
......@@ -30,9 +30,9 @@ describe('runAnalysis method', () => {
it('resolves if job state is successful', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve(123))
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({state: 'SUCCESS', result: 123}))
.and.returnValue(Promise.resolve({data: {state: 'SUCCESS', result: 123}}))
runAnalysis({name: '', args: {}})
.then(response => {
expect(response).toBe(123)
......@@ -43,9 +43,9 @@ describe('runAnalysis method', () => {
it('rejects if job state is unsuccessful', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve(123))
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValue(Promise.resolve({state: 'FAILURE', result: ''}))
.and.returnValue(Promise.resolve({data: {state: 'FAILURE', result: ''}}))
runAnalysis({name: '', args: {}})
.then(done.fail)
.catch(done)
......@@ -53,13 +53,13 @@ describe('runAnalysis method', () => {
it('does wait for job state to switch from PENDING to final state', done => {
spyOn(store.getters.requestManager, 'createAnalysis')
.and.returnValue(Promise.resolve(123))
.and.returnValue(Promise.resolve({data: {job_id: 123}}))
spyOn(store.getters.requestManager, 'getAnalysisStatus')
.and.returnValues(
Promise.resolve({state: 'PENDING', result: ''}),
Promise.resolve({state: 'PENDING', result: ''}),
Promise.resolve({state: 'PENDING', result: ''}),
Promise.resolve({state: 'SUCCESS', result: 123})
Promise.resolve({data: {state: 'PENDING', result: ''}}),
Promise.resolve({data: {state: 'PENDING', result: ''}}),
Promise.resolve({data: {state: 'PENDING', result: ''}}),
Promise.resolve({data: {state: 'SUCCESS', result: 123}})
)
runAnalysis({name: '', args: {}})
.then(response => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment