import React from 'react';
import { ScrollView } from 'react-native';
import { shallow } from 'enzyme';
import Main from '../main';

describe('Main', () => {
  let wrapper;

  beforeEach(() => {
    wrapper = shallow(<Main />);
  });

  afterEach(() => {
    wrapper.unmount();
  });

  it('should render a ScrollView component', () => {
    expect(wrapper.find(ScrollView)).toHaveLength(1);
  });

  it('should render the news list', () => {
    const newsList = wrapper.instance().renderNewsList();
    expect(newsList.props.style.width).toBeDefined();
  });

  it('should render a news item', () => {
    const item = {
      imageURL: 'https://example.com/image.jpg',
      date: '2022-01-01',
      title: 'Example News',
      content: '<p>Example content</p>'
    };
    const newsItem = wrapper.instance().renderNews(item);
    expect(newsItem.props.style.height).toBeDefined();
    expect(newsItem.props.style.width).toBeDefined();
  });

  it('should render the banner list', () => {
    const bannerList = wrapper.instance().renderBannerList();
    expect(bannerList.props.style.width).toBeDefined();
    expect(bannerList.props.style.justifyContent).toEqual('center');
    expect(bannerList.props.style.alignItems).toEqual('center');
    expect(bannerList.props.style.marginTop).toBeDefined();
  });

  it('should render the recommend list', () => {
    const recommendList = wrapper.instance().renderRecommendList();
    expect(recommendList.props.style.width).toBeDefined();
    expect(recommendList.props.style.marginTop).toBeDefined();
  });
});