fix tests

This commit is contained in:
Vyrtsev Mikhail
2019-04-20 20:58:58 +03:00
parent 68294fd3d2
commit 7e84b356a2
4 changed files with 27 additions and 6 deletions
+6 -4
View File
@@ -4,10 +4,10 @@ import { setCollapse } from './actions';
import { THREAD_SET_COLLAPSE } from './types';
describe('collapsedThreads', () => {
const comment = { id: 'some-id' } as Comment;
it('should set collapsed to true', () => {
const state = { collapsedThreads: {} };
const comment = { id: 'some-id' } as Comment;
const node = { comment, replies: [] };
const state = { collapsedThreads: {}, comments: [node] };
const dispatch = jest.fn();
const getState = jest.fn(() => state) as any;
@@ -20,9 +20,11 @@ describe('collapsedThreads', () => {
});
it('should collapse toggled', () => {
const comment = { id: 'some-id' } as Comment;
const node = { comment, replies: [] };
const dispatch = jest.fn();
const getState = jest.fn();
getState.mockReturnValue({ collapsedThreads: { 'some-id': true } });
getState.mockReturnValue({ collapsedThreads: { 'some-id': true }, comments: [node] });
setCollapse(comment.id)(dispatch, getState, undefined);
expect(dispatch).toBeCalledWith({
+20
View File
@@ -1,3 +1,23 @@
import { StaticStore } from '@app/common/static_store';
require('document-register-element/pony')(window);
beforeEach(() => {
StaticStore.config = {
admin_email: 'admin@remark42.com',
admins: ['admin'],
auth_providers: ['dev', 'google'],
critical_score: -15,
low_score: -5,
edit_duration: 300,
max_comment_size: 3000,
max_image_size: 5000,
positive_score: false,
readonly_age: 100,
version: 'jest-test',
};
});
export function createDomContainer(setup: (domContainer: HTMLElement) => void): void {
let domContainer: HTMLElement | null = null;
beforeAll(() => {
+1 -1
View File
@@ -11,5 +11,5 @@ module.exports = {
'\\.scss$': '<rootDir>/app/testUtils/mockStyles.js',
'@app/(.*)': '<rootDir>/app/$1',
},
setupFilesAfterEnv: ['<rootDir>/setup-jest-env.js'],
setupFilesAfterEnv: ['<rootDir>/app/testUtils/index.ts'],
};
-1
View File
@@ -1 +0,0 @@
require('document-register-element/pony')(window);