-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pierre Trollé
committed
Jun 23, 2017
1 parent
779d6e8
commit 5ee1a7a
Showing
3 changed files
with
134 additions
and
132 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
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
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 |
---|---|---|
@@ -1,210 +1,212 @@ | ||
import Vue from 'vue' | ||
import VueResource from 'vue-resource' | ||
import VueAnalytics from 'vue-analytics' | ||
import JobList from '@/components/JobList' | ||
import authentication from '@/services/authentication' | ||
import jobsApi from '@/api/jobs' | ||
|
||
Vue.use(VueResource) | ||
import Vue from 'vue'; | ||
import VueResource from 'vue-resource'; | ||
import VueAnalytics from 'vue-analytics'; | ||
import JobList from '@/components/JobList'; | ||
import authentication from '@/services/authentication'; | ||
import jobsApi from '@/api/jobs'; | ||
|
||
Vue.use(VueResource); | ||
Vue.use(VueAnalytics, { | ||
id: `${process.env.ANALYTICS_ID}`, | ||
}) | ||
id: `${process.env.ANALYTICS_ID}`, | ||
}); | ||
|
||
describe('JobList.vue', () => { | ||
|
||
let Constructor | ||
let Constructor; | ||
|
||
beforeEach(() => { | ||
beforeEach(() => { | ||
|
||
sinon.stub(authentication, 'isAuthenticated') | ||
sinon.stub(jobsApi, 'fetchAll') | ||
Constructor = Vue.extend(JobList) | ||
sinon.stub(authentication, 'isAuthenticated'); | ||
sinon.stub(jobsApi, 'fetchAll'); | ||
Constructor = Vue.extend(JobList); | ||
|
||
}) | ||
}); | ||
|
||
afterEach(() => { | ||
afterEach(() => { | ||
|
||
authentication.isAuthenticated.restore() | ||
jobsApi.fetchAll.restore() | ||
authentication.isAuthenticated.restore(); | ||
jobsApi.fetchAll.restore(); | ||
|
||
}) | ||
}); | ||
|
||
it('should get job data from API', () => { | ||
it('should get job data from API', () => { | ||
|
||
// given | ||
authentication.isAuthenticated.returns(true) | ||
authentication.isAuthenticated.returns(true); | ||
|
||
// when | ||
new Constructor().$mount() | ||
new Constructor().$mount(); | ||
|
||
// then | ||
expect(authentication.isAuthenticated).to.have.been.called | ||
expect(authentication.isAuthenticated).to.have.been.called; | ||
|
||
}) | ||
}); | ||
|
||
describe('#trackEvent', () => { | ||
describe('#trackEvent', () => { | ||
|
||
it('should check analytics', () => { | ||
it('should check analytics', () => { | ||
|
||
// given | ||
|
||
authentication.isAuthenticated.returns(true) | ||
const component = new Constructor().$mount() | ||
authentication.isAuthenticated.returns(true); | ||
const component = new Constructor().$mount(); | ||
|
||
sinon.stub(component.$ga, 'event') | ||
component.$ga.event.returns(true) | ||
sinon.stub(component.$ga, 'event'); | ||
component.$ga.event.returns(true); | ||
|
||
// when | ||
component.trackEvent() | ||
component.trackEvent(); | ||
|
||
// then | ||
expect(component.$ga.event).to.have.been.calledWith( | ||
{ | ||
eventCategory: 'Job List', | ||
eventAction: 'click', | ||
eventLabel: 'I am interested', | ||
eventValue: null, | ||
}) | ||
expect(component.$ga.event).to.have.been.calledWith( | ||
{ | ||
eventCategory: 'Job List', | ||
eventAction: 'click', | ||
eventLabel: 'I am interested', | ||
eventValue: null, | ||
}); | ||
|
||
// after | ||
component.$ga.event.restore() | ||
}) | ||
component.$ga.event.restore(); | ||
|
||
}); | ||
|
||
// skip en attente du fetchActivities | ||
it.skip('on click on button job__apply-button', () => { | ||
it.skip('on click on button job__apply-button', () => { | ||
|
||
// given | ||
|
||
authentication.isAuthenticated.returns(true) | ||
const component = new Constructor().$mount() | ||
authentication.isAuthenticated.returns(true); | ||
const component = new Constructor().$mount(); | ||
|
||
sinon.stub(component.$ga, 'event') | ||
component.$ga.event.returns(true) | ||
sinon.stub(component.$ga, 'event'); | ||
component.$ga.event.returns(true); | ||
|
||
// when | ||
component.$el.querySelector('button.job__apply-button').click() | ||
component.$el.querySelector('button.job__apply-button').click(); | ||
|
||
// then | ||
expect(component.$ga.event).to.have.been.calledWith( | ||
{ | ||
eventCategory: 'Job List', | ||
eventAction: 'click', | ||
eventLabel: 'I am interested', | ||
eventValue: null, | ||
}) | ||
expect(component.$ga.event).to.have.been.calledWith( | ||
{ | ||
eventCategory: 'Job List', | ||
eventAction: 'click', | ||
eventLabel: 'I am interested', | ||
eventValue: null, | ||
}); | ||
|
||
// after | ||
component.$ga.event.restore() | ||
}) | ||
component.$ga.event.restore(); | ||
|
||
}); | ||
|
||
}) | ||
}); | ||
|
||
it.skip('should render as many jobs as received from the API', () => { | ||
it.skip('should render as many jobs as received from the API', () => { | ||
|
||
// given | ||
authentication.isAuthenticated.returns(true) | ||
authentication.isAuthenticated.returns(true); | ||
|
||
// given | ||
jobsApi.fetchAll.resolves([{ | ||
activity: {}, | ||
project: {}, | ||
}, { | ||
activity: {}, | ||
project: {}, | ||
}, { | ||
activity: {}, | ||
project: {}, | ||
}]) | ||
jobsApi.fetchAll.resolves([{ | ||
activity: {}, | ||
project: {}, | ||
}, { | ||
activity: {}, | ||
project: {}, | ||
}, { | ||
activity: {}, | ||
project: {}, | ||
}]); | ||
|
||
// when | ||
const vm = new Constructor().$mount() | ||
const vm = new Constructor().$mount(); | ||
|
||
// then | ||
const jobCards = vm.$el.querySelectorAll('.job-card') | ||
expect(jobCards.length).to.equal(3) | ||
const jobCards = vm.$el.querySelectorAll('.job-card'); | ||
expect(jobCards.length).to.equal(3); | ||
|
||
}) | ||
}); | ||
|
||
it.skip('should render the details of a job', () => { | ||
it.skip('should render the details of a job', () => { | ||
|
||
// given | ||
authentication.isAuthenticated.returns(true) | ||
|
||
jobsApi.fetchAll.callFakes(() => { | ||
|
||
console.log('COUCOU') | ||
return Promise.resolve([{ | ||
id: 2, | ||
activity: { | ||
title: 'Tech Lead', | ||
}, | ||
project: { | ||
id: 123456, | ||
status: 'proposal-in-progress', | ||
name: 'Delivery PUBLICIS / TITAN', | ||
customer: { | ||
name: 'La Poste - Courrier', | ||
}, | ||
start_date: 'juillet 2017', | ||
duration: '10 mois', | ||
location: 'OCTO', | ||
business_contact: { | ||
nickname: 'ABC', | ||
}, | ||
mission_director: { | ||
nickname: 'XYZ', | ||
}, | ||
}, | ||
}]) | ||
|
||
}) | ||
authentication.isAuthenticated.returns(true); | ||
|
||
jobsApi.fetchAll.callFakes(() => { | ||
|
||
console.log('COUCOU'); | ||
return Promise.resolve([{ | ||
id: 2, | ||
activity: { | ||
title: 'Tech Lead', | ||
}, | ||
project: { | ||
id: 123456, | ||
status: 'proposal-in-progress', | ||
name: 'Delivery PUBLICIS / TITAN', | ||
customer: { | ||
name: 'La Poste - Courrier', | ||
}, | ||
start_date: 'juillet 2017', | ||
duration: '10 mois', | ||
location: 'OCTO', | ||
business_contact: { | ||
nickname: 'ABC', | ||
}, | ||
mission_director: { | ||
nickname: 'XYZ', | ||
}, | ||
}, | ||
}]); | ||
|
||
}); | ||
|
||
// when | ||
const vm = new Constructor().$mount() | ||
const vm = new Constructor().$mount(); | ||
|
||
// then | ||
const firstJobCard = vm.$el.querySelectorAll('.job-card')[0] | ||
expect(firstJobCard.querySelector('.job__title').textContent).to.equal('Tech Lead') | ||
expect(firstJobCard.querySelector('.job__mission').textContent).to.equal('Delivery PUBLICIS / TITAN') | ||
expect(firstJobCard.querySelector('.job__client').textContent).to.equal('La Poste - Courrier') | ||
expect(firstJobCard.querySelector('.job__start-date').textContent).to.equal('juillet 2017') | ||
expect(firstJobCard.querySelector('.job__duration').textContent).to.equal('10 mois') | ||
expect(firstJobCard.querySelector('.job__location').textContent).to.equal('OCTO') | ||
expect(firstJobCard.querySelector('.job__content').getAttribute('href')).to.equal('https://link.to.octopod.octo.com/projects/123456') | ||
const firstJobCard = vm.$el.querySelectorAll('.job-card')[0]; | ||
expect(firstJobCard.querySelector('.job__title').textContent).to.equal('Tech Lead'); | ||
expect(firstJobCard.querySelector('.job__mission').textContent).to.equal('Delivery PUBLICIS / TITAN'); | ||
expect(firstJobCard.querySelector('.job__client').textContent).to.equal('La Poste - Courrier'); | ||
expect(firstJobCard.querySelector('.job__start-date').textContent).to.equal('juillet 2017'); | ||
expect(firstJobCard.querySelector('.job__duration').textContent).to.equal('10 mois'); | ||
expect(firstJobCard.querySelector('.job__location').textContent).to.equal('OCTO'); | ||
expect(firstJobCard.querySelector('.job__content').getAttribute('href')).to.equal('https://link.to.octopod.octo.com/projects/123456'); | ||
|
||
}) | ||
}); | ||
|
||
it.skip('should render the appropriate status class', () => { | ||
it.skip('should render the appropriate status class', () => { | ||
|
||
// given | ||
authentication.isAuthenticated.returns(true) | ||
authentication.isAuthenticated.returns(true); | ||
|
||
jobsApi.fetchAll.resolves([{ | ||
project: {status: 'proposal-in-progress'}, | ||
}]) | ||
jobsApi.fetchAll.resolves([{ | ||
project: { status: 'proposal-in-progress' }, | ||
}]); | ||
|
||
// when | ||
const vm = new Constructor().$mount() | ||
const vm = new Constructor().$mount(); | ||
|
||
// then | ||
const firstJobCard = vm.$el.querySelectorAll('.job-card')[0] | ||
expect(firstJobCard.querySelector('.job__status').getAttribute('class')).to.contain('job__status--proposal-in-progress') | ||
const firstJobCard = vm.$el.querySelectorAll('.job-card')[0]; | ||
expect(firstJobCard.querySelector('.job__status').getAttribute('class')).to.contain('job__status--proposal-in-progress'); | ||
|
||
}) | ||
}); | ||
|
||
it.skip('should add number of available jobs', () => { | ||
it.skip('should add number of available jobs', () => { | ||
|
||
// given | ||
authentication.isAuthenticated.returns(true) | ||
jobsApi.fetchAll.resolves([{}, {}, {}, {}]) | ||
authentication.isAuthenticated.returns(true); | ||
jobsApi.fetchAll.resolves([{}, {}, {}, {}]); | ||
|
||
// when | ||
const vm = new Constructor().$mount() | ||
const vm = new Constructor().$mount(); | ||
|
||
// then | ||
expect(vm.$el.querySelector('.job-results__title').textContent).to.contain('4') | ||
expect(vm.$el.querySelector('.job-results__title').textContent).to.contain('4'); | ||
|
||
}) | ||
}); | ||
|
||
}) | ||
}); | ||
|