This repository was archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathstore.spec.js
61 lines (46 loc) · 1.46 KB
/
store.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { createStore } from '../../../../src/store/store';
describe('Store', () => {
describe('states', () => {
let store;
beforeEach(() => { store = createStore(); });
describe('@searchTerm', () => {
it('should have an empty string as initial value', () => {
expect(store.state.searchTerm).to.eql('');
});
});
describe('@gifs', () => {
it('should have an empty array as initial value', () => {
expect(store.state.gifs).to.eql([]);
});
});
describe('@selectedGif', () => {
it('should have an empty object as initial value', () => {
expect(store.state.selectedGif).to.eql({});
});
});
});
describe('mutations', () => {
let store;
beforeEach(() => { store = createStore(); });
describe('setSearchTerm', () => {
it('should set the search term', () => {
store.commit('setSearchTerm', 'test term');
expect(store.state.searchTerm).to.eql('test term');
});
});
describe('setGifs', () => {
it('should set the gifs', () => {
const gifs = [{ title: 'gif1' }, { title: 'gif2' }];
store.commit('setGifs', gifs);
expect(store.state.gifs).to.eql(gifs);
});
});
describe('selectGif', () => {
it('should set the selected gif', () => {
const gif = { title: 'gif1' };
store.commit('selectGif', gif);
expect(store.state.selectedGif).to.eql(gif);
});
});
});
});