Home Reference Source

application/__tests__/components/common/error-box-test.js

jest.unmock('./../../../components/common/errors');
jest.unmock('./../../../services/base-service');
jest.unmock('./../../../services/error-service');

jest.unmock('./../../../alt');

import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
import Immutable from 'immutable';
import sinon from 'sinon';
import AltTestingUtils from 'alt-utils/lib/AltTestingUtils';

import ErrorViewer from './../../../components/common/errors';
import {ErrorService, ErrorsStore} from './../../../services/error-service';

describe('ErrorViewerComponent', () => {
    let spy;

    beforeEach(() => {
        jasmine.clock().uninstall();
        jasmine.clock().install();
    });

    afterEach(() => {
        jasmine.clock().uninstall();
    });

    it('loads default state', () => {
        const errorBox = TestUtils.renderIntoDocument(
            <ErrorViewer />
        );
        errorBox.componentWillMount();

        ErrorService.add('error', 'test error');
        jasmine.clock().tick(2);

        expect(errorBox.state.error.message).toEqual('test error');
    });
});