Client: Guild page and mix changes (#8533)
* update deps * add guilds page * improve karma conf, add tests for actions
This commit is contained in:
@@ -2,8 +2,17 @@
|
||||
// and babel-runtime doesn't affect external libraries
|
||||
require('babel-polyfill');
|
||||
|
||||
// require all test files (files that ends with .spec.js)
|
||||
let testsContext = require.context('./specs', true, /\.spec$/);
|
||||
// Automatically setup SinonJS' sandbox for each test
|
||||
beforeEach(() => {
|
||||
global.sandbox = sinon.sandbox.create();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.sandbox.restore();
|
||||
});
|
||||
|
||||
// require all test files
|
||||
let testsContext = require.context('./specs', true, /\.js$/);
|
||||
testsContext.keys().forEach(testsContext);
|
||||
|
||||
// require all .vue and .js files except main.js for coverage.
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = function (config) {
|
||||
// http://karma-runner.github.io/0.13/config/browsers.html
|
||||
// 2. add it to the `browsers` array below.
|
||||
browsers: ['PhantomJS'],
|
||||
frameworks: ['mocha', 'sinon-chai'],
|
||||
frameworks: ['mocha', 'sinon-stub-promise', 'sinon-chai', 'chai-as-promised', 'chai'],
|
||||
reporters: ['spec', 'coverage'],
|
||||
files: ['./index.js'],
|
||||
preprocessors: {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { fetchAll as fetchAllGuilds } from 'client/store/actions/guilds';
|
||||
import axios from 'axios';
|
||||
import store from 'client/store';
|
||||
|
||||
describe('guilds actions', () => {
|
||||
it('fetchAll', async () => {
|
||||
const guilds = [{_id: 1}];
|
||||
sandbox
|
||||
.stub(axios, 'get')
|
||||
.withArgs('/api/v3/groups?type=publicGuilds')
|
||||
.returns(Promise.resolve({data: {data: guilds}}));
|
||||
|
||||
await fetchAllGuilds(store);
|
||||
|
||||
expect(store.state.guilds).to.equal(guilds);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { fetchUserTasks } from 'client/store/actions/tasks';
|
||||
import axios from 'axios';
|
||||
import store from 'client/store';
|
||||
|
||||
describe('tasks actions', () => {
|
||||
it('fetchUserTasks', async () => {
|
||||
const tasks = [{_id: 1}];
|
||||
sandbox.stub(axios, 'get').withArgs('/api/v3/tasks/user').returns(Promise.resolve({data: {data: tasks}}));
|
||||
|
||||
await fetchUserTasks(store);
|
||||
|
||||
expect(store.state.tasks).to.equal(tasks);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { fetch as fetchUser } from 'client/store/actions/user';
|
||||
import axios from 'axios';
|
||||
import store from 'client/store';
|
||||
|
||||
describe('user actions', () => {
|
||||
it('fetch', async () => {
|
||||
const user = {_id: 1};
|
||||
sandbox.stub(axios, 'get').withArgs('/api/v3/user').returns(Promise.resolve({data: {data: user}}));
|
||||
|
||||
await fetchUser(store);
|
||||
|
||||
expect(store.state.user).to.equal(user);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user