Fix endpoint not being update correctly
This commit is contained in:
parent
398bdce190
commit
9cc3500e25
2 changed files with 44 additions and 2 deletions
|
@ -40,7 +40,6 @@ export default {
|
|||
return {
|
||||
isLoading: false,
|
||||
dropdownContent: '',
|
||||
endpoint: this.stage.dropdown_path,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -73,7 +72,7 @@ export default {
|
|||
},
|
||||
|
||||
fetchJobs() {
|
||||
this.$http.get(this.endpoint)
|
||||
this.$http.get(this.stage.dropdown_path)
|
||||
.then((response) => {
|
||||
this.dropdownContent = response.json().html;
|
||||
this.isLoading = false;
|
||||
|
|
|
@ -83,4 +83,47 @@ describe('Pipelines stage component', () => {
|
|||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('update endpoint correctly', () => {
|
||||
const updatedInterceptor = (request, next) => {
|
||||
if (request.url === 'bar') {
|
||||
next(request.respondWith(JSON.stringify({ html: 'this is the updated content' }), {
|
||||
status: 200,
|
||||
}));
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
Vue.http.interceptors.push(updatedInterceptor);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Vue.http.interceptors = _.without(
|
||||
Vue.http.interceptors, updatedInterceptor,
|
||||
);
|
||||
});
|
||||
|
||||
it('should update the stage to request the new endpoint provided', (done) => {
|
||||
component.stage = {
|
||||
status: {
|
||||
group: 'running',
|
||||
icon: 'running',
|
||||
title: 'running',
|
||||
},
|
||||
dropdown_path: 'bar',
|
||||
};
|
||||
|
||||
Vue.nextTick(() => {
|
||||
component.$el.querySelector('button').click();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(
|
||||
component.$el.querySelector('.js-builds-dropdown-container ul').textContent.trim(),
|
||||
).toEqual('this is the updated content');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue