{"size": 1997, "ext": "js", "max_stars_repo_path": "test/InjectComopnent.test.js", "max_stars_repo_name": "AimWhy/rdeco", "max_stars_repo_stars_event_min_datetime": "2021-11-09T07:17:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-22T02:32:12.000Z", "max_issues_repo_path": "test/InjectComopnent.test.js", "max_issues_repo_name": "AimWhy/rdeco", "max_issues_repo_issues_event_min_datetime": "2021-11-19T03:44:59.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-24T02:27:26.000Z", "max_forks_repo_path": "test/InjectComopnent.test.js", "max_forks_repo_name": "AimWhy/rdeco", "max_forks_repo_forks_event_min_datetime": "2021-11-26T12:22:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-12T04:51:01.000Z"}
{"max_stars_count": 18, "max_issues_count": 3, "max_forks_count": 3, "avg_line_length": 21.7065217391, "max_line_length": 75, "alphanum_fraction": 0.5107661492}
/* eslint-disable react/prop-types */
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
import React from 'react'
import ReactDOM from 'react-dom'
import { render, fireEvent, waitFor, screen } from '@testing-library/react'
import { act } from 'react-dom/test-utils'
import '@testing-library/jest-dom/extend-expect'
import {
  createComponent,
  create,
  withComponent,
  Inject,
  InjectComponent,
} from '@rdeco/web-app-sdk'
import { combination } from '@rdeco/core/src'

test('React Inject Component Test', async () => {
  // const Tag = createComponent({
  //   name: '@test/tag',
  //   view: {
  //     render() {
  //       return <div role="tag">tag</div>
  //     },
  //   },
  // })
  const Tag1 = createComponent({
    name: '@test/tag1',
    view: {
      render() {
        return (
          <div role="tag1">
            tag1 <div role="id">{this.props.params.id}</div>{' '}
          </div>
        )
      },
    },
  })
  // create({
  //   name: '@test/tag-module',
  //   exports: {
  //     render(el, props, Context) {
  //       ReactDOM.render(<Tag></Tag>, el)
  //     },
  //   },
  // })
  create({
    name: '@test/tag-module1',
    exports: {
      getComponent(next) {
        next(Tag1)
      },
    },
  })
  const Test = createComponent({
    name: '@test/com',
    state: {
      params: {
        id: 0,
      },
    },
    controller: {
      onMount() {
        this.setter.params({
          id: 1,
        })
      },
    },
    view: {
      render() {
        return (
          <div>
            <InjectComponent
              name="@test/tag-module1"
              params={this.state.params}
            ></InjectComponent>
          </div>
        )
      },
    },
  })
  const Sleep = new Promise((resolve) => {
    setTimeout(() => {
      resolve()
    }, 1000)
  })
  render(<Test></Test>)
  await Sleep.then()
  expect(screen.getByRole('tag1')).toHaveTextContent('tag1')
  expect(screen.getByRole('id')).toHaveTextContent('1')
})
