import React, { useEffect } from 'react';
import { teamixTest, productCalculate } from '@teamix/testing-capability';
import result from './data';

const InnerTest = () => {
  useEffect(() => {
    // 环境配置
    window.postMessage(
      {
        source: 'teamix-test-devtools',
        url: window.location.href,
        event: 'getModuleInfo',
        moduleName: '@teamix/doc-helper',
        moduleVersion: '1.33.14',
        moduleType: 'ApsaraStack',
        componentName: 'DocHelper',
      },
      '*',
    );
  }, []);

  useEffect(() => {
    setTimeout(async () => {
      const testA = await teamixTest({
        testItem: ['MODULE'],
      });

      console.log('依赖测试 => ', testA);
      console.log(productCalculate([testA, ...result]));
    }, 1000);
  }, []);

  return <section id="module">依赖测试</section>;
};

export default InnerTest;
