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
1 parent
0aa1541
commit 28b7659
Showing
7 changed files
with
5,903 additions
and
3,600 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
plugins: { | ||
autoprefixer: {} | ||
} | ||
} | ||
autoprefixer: {}, | ||
}, | ||
}; |
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,17 @@ | ||
module.exports = { | ||
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'], | ||
transform: { | ||
'^.+\\.vue$': 'vue-jest', | ||
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': | ||
'jest-transform-stub', | ||
'^.+\\.jsx?$': 'babel-jest', | ||
}, | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
}, | ||
snapshotSerializers: ['jest-serializer-vue'], | ||
testMatch: [ | ||
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', | ||
], | ||
testURL: 'http://localhost/', | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
env: { | ||
jest: true, | ||
}, | ||
}; |
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,56 @@ | ||
import { shallowMount, createLocalVue } from '@vue/test-utils'; | ||
import Vuex from 'vuex'; | ||
import _ from 'lodash'; | ||
|
||
import Quote from '@/components/Quote.vue'; | ||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
|
||
describe('Quote.vue', () => { | ||
let store; | ||
let quote = { | ||
id: 1, | ||
text: ['Watson: excellent!', 'Sherlock: elementary.'], | ||
author: 'Sherlock', | ||
interlocutor: 'Watson', | ||
date: '2018-01-01', | ||
likes: 0, | ||
likedBy: [], | ||
}; | ||
|
||
beforeEach(() => { | ||
store = new Vuex.Store({ | ||
state: { | ||
user: { | ||
uid: '1', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('renders quote', () => { | ||
const wrapper = shallowMount(Quote, { | ||
propsData: { | ||
quote: _.cloneDeep(quote), | ||
}, | ||
store, | ||
localVue, | ||
stubs: ['router-link'], | ||
}); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('highlight like button if user has liked', () => { | ||
const wrapper = shallowMount(Quote, { | ||
propsData: { | ||
quote: _.defaults({ likes: 1, likedBy: ['1'] }, quote), | ||
}, | ||
store, | ||
localVue, | ||
stubs: ['router-link'], | ||
}); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
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,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Quote.vue highlight like button if user has liked 1`] = ` | ||
<div class="quote"> | ||
<div class="quote__body"> | ||
<ul class="list-stacked list-stacked--divided"> | ||
<li>Watson: excellent!</li> | ||
<li>Sherlock: elementary.</li> | ||
</ul> | ||
</div> | ||
<div class="quote__meta"><strong>Sherlock</strong> <span> à <strong>Watson</strong></span> | ||
le <router-link-stub to="/quote/1" class="text-nowrap">1 janvier 2018</router-link-stub> <button type="button" title="Je n’aime plus" class="btn btn--bare like like--liked"> | ||
<heart-alt-icon-stub class="like__icon icon"></heart-alt-icon-stub> | ||
1 | ||
</button></div> | ||
</div> | ||
`; | ||
|
||
exports[`Quote.vue renders quote 1`] = ` | ||
<div class="quote"> | ||
<div class="quote__body"> | ||
<ul class="list-stacked list-stacked--divided"> | ||
<li>Watson: excellent!</li> | ||
<li>Sherlock: elementary.</li> | ||
</ul> | ||
</div> | ||
<div class="quote__meta"><strong>Sherlock</strong> <span> à <strong>Watson</strong></span> | ||
le <router-link-stub to="/quote/1" class="text-nowrap">1 janvier 2018</router-link-stub> <button type="button" title="J’aime" class="btn btn--bare like"> | ||
<heart-icon-stub class="like__icon icon"></heart-icon-stub> | ||
0 | ||
</button></div> | ||
</div> | ||
`; |