import React from 'react';
import renderer from 'react-test-renderer';
import { ServerStats } from './ServerStats';
import { createNavModel } from 'test/mocks/common';
import { ServerStat } from '../apis';

describe('ServerStats', () => {
  it('Should render table with stats', done => {
    const navModel = createNavModel('Admin', 'stats');
    const stats: ServerStat[] = [{ name: 'Total dashboards', value: 10 }, { name: 'Total Users', value: 1 }];

    let getServerStats = () => {
      return Promise.resolve(stats);
    };

    const page = renderer.create(<ServerStats navModel={navModel} getServerStats={getServerStats} />);

    setTimeout(() => {
      expect(page.toJSON()).toMatchSnapshot();
      done();
    });
  });
});
