import * as React from 'react';

import App from './App';
import BaseDriver from '../../../test/BaseDriver';
import MockApi from '../../utils/mock-api';

export default class AppDriver extends BaseDriver {
  private mockApi;

  constructor() {
    super();
    this.mockApi = new MockApi();
  }

  given = {
    order: () => {
      this.mockApi.order('111');
      return this;
    },
  };

  when = {
    render: () => {
      this._render(<App/>);
      return this;
    },
  };

  has = {
    app: () => this.get.app().exists(),
    widget: () => this.get.widget().exists(),
    spinner: () => this.get.spinner().exists(),
  };

  get = {
    app: () => this.findByDataHook('wcn-payment-app'),
    widget: () => this.findByDataHook('wcn-payment-widget'),
    spinner: () => this.findByDataHook('wcn-spinner-main'),
    error: () => this.findByDataHook('wcn-general-error-message').text(),
  };
}
