package com.github.bogdanlivadariu.reporting.cucumber.builder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.JAXBException;

import org.junit.Before;
import org.junit.Test;

import com.github.bogdanlivadariu.reporting.cucumber.helpers.SpecialProperties;

public class CucumberJsTest {

    private CucumberReportBuilder builder;

    private AllFeatureReports reports;

    @Before
    public void setUp() throws JAXBException, IOException {
        List<String> jsonReports = new ArrayList<>();

        String cucumberJsReport = AllFeatureReportsTest.class.getResource("/cucumber-js.json").getPath();

        jsonReports.add(cucumberJsReport);

        builder = new CucumberReportBuilder(jsonReports, "output", new SpecialProperties());
        reports = new AllFeatureReports("title", builder.getProcessedFeatures());

    }

    @Test
    public void featureSizeTest() {
        assertEquals(1, reports.getFeatures().size());
        reports.getPageTitle();
        reports.getScenariosTotal();
        reports.getScenariosTotalFailed();
        reports.getScenariosTotalPassed();
        reports.getStepsTotal();
    }

    @Test
    public void stepsTest() {
        assertEquals(Integer.valueOf(6), reports.getStepsTotal());
        assertEquals(Integer.valueOf(0), reports.getStepsTotalFailed());
        assertEquals(Integer.valueOf(4), reports.getStepsTotalPassed());
        assertEquals(Integer.valueOf(1), reports.getStepsTotalSkipped());
        assertEquals(Integer.valueOf(1), reports.getStepsTotalUndefined());
    }

    @Test
    public void builderShouldFail() throws IOException {
        assertFalse(builder.writeReportsOnDisk());
    }
}

@@ -145,16 +145,59 @@
 rtFalse;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -436,16 +436,161 @@
 perties;
+%0Aimport com.github.bogdanlivadariu.reporting.cucumber.json.models.Element;%0Aimport com.github.bogdanlivadariu.reporting.cucumber.json.models.Step;
 %0A%0Apublic
@@ -1857,32 +1857,171 @@
 ined());%0A    %7D%0A%0A
+    @Test%0A    public void hidenTest() %7B%0A        assertTrue(reports.getFeatures().get(0).getElements()%5B0%5D.getSteps()%5B5%5D.isHidden());%0A    %7D%0A%0A
     @Test%0A    pu

add test for isHidden for cucumber-js reports