import {FakeWidget, FakeService} from 'tests/__fixtures__/services';

export const DashboardsFactory = () => {
  return [
    {
      id: 'testing',
      name: 'Testing',
      services: [
        new FakeService({
          instance: 'fake_instance',
          widgetComponent: FakeWidget,
          characteristics: {
            spam: true,
          },
          layout: {
            x: 0,
            y: 0,
            w: 1,
            h: 1,
          },
        }),
        new FakeService({
          instance: 'other_fake_instance',
          widgetComponent: FakeWidget,
          characteristics: {
            spam: true,
          },
          layout: {
            x: 0,
            y: 1,
            w: 1,
            h: 1,
          },
        }),
      ],
    },
  ];
};

export const DashboardsJSONFactory = (dashboards) => {
  dashboards = dashboards || DashboardsFactory();

  return dashboards.map((dashboard) => {
    return {
      ...dashboard,
      services: dashboard.services.map((service) => {
        return service.toJSON();
      }),
    };
  });
};
