/* eslint-disable */
import { useStrict } from "mobx";
import ProjectStore from "../../stores/domain/ProjectStore";
import Suite from "../../models/Suite";
import TestCase from "../../models/TestCase";

useStrict(true);

describe("Suite model", () => {
  it("new suite should be named 'Utitled Suite'", () => {
    expect((new Suite()).name).toBe("Untitled Suite");
  });
  it("Suites should have randomly generated identifiers", () => {
    expect((new Suite()).id).not.toBe((new Suite()).id);
  });
  it("should rename the suite", () => {
    const suite = new Suite();
    suite.setName("test");
    expect(suite.name).toBe("test");
  });
  it("should add a new Test Case", () => {
    const store = new ProjectStore();
    const suite = new Suite();
    const test = new TestCase();
    store.addTestCase(test);
    expect(suite.tests.length).toBe(0);
    suite.addTestCase(test);
    expect(suite.tests.length).toBe(1);
  });
  it("should throw if no Test Case was given", () => {
    const suite = new Suite();
    expect(() => suite.addTestCase()).toThrowError("Expected to receive TestCase instead received undefined");
  });
  it("should throw if a different type was given", () => {
    const suite = new Suite();
    expect(() => suite.addTestCase(1)).toThrowError("Expected to receive TestCase instead received Number");
  });
  it("should remove a Test Case from the suite", () => {
    const store = new ProjectStore();
    const suite = new Suite();
    const test = new TestCase();
    store.addTestCase(test);
    suite.addTestCase(test);
    expect(suite.tests.length).toBe(1);
    suite.removeTestCase(test);
    expect(suite.tests.length).toBe(0);
  });
  it("should do nothing if removed a non-existent test", () => {
    const store = new ProjectStore();
    const suite = new Suite();
    const test = new TestCase();
    store.addTestCase(test);
    suite.addTestCase(test);
    expect(suite.tests.length).toBe(1);
    suite.removeTestCase(new TestCase());
    expect(suite.tests.length).toBe(1);
  });
  it("should replace the tests in the suite", () => {
    const store = new ProjectStore();
    const suite = new Suite();
    store.createTestCase();
    store.createTestCase();
    store.createTestCase();
    expect(suite.tests.length).toBe(0);
    suite.replaceTestCases(store.tests);
    expect(suite.tests.length).toBe(3);
  });
  it("should load from JS", () => {
    const jsRep = {
      id: "1",
      name: "test suite",
      tests: []
    };
    const suite = Suite.fromJS(jsRep);
    expect(suite.id).toBe(jsRep.id);
    expect(suite.name).toBe(jsRep.name);
    expect(suite instanceof Suite).toBeTruthy();
  });
  it("should load tests from JS", () => {
    const jsRep = {
      id: "1",
      name: "test suite",
      tests: [
        {
          id: "2",
          name: "first test"
        },
        {
          id: "3",
          name: "second test"
        }
      ]
    };
    const suite = Suite.fromJS(jsRep);
    expect(suite.tests.length).toBe(2);
    expect(suite.tests[0] instanceof TestCase).toBeTruthy();
  });
});

@@ -2690,39 +2690,54 @@
  =%3E %7B%0A    const 
-jsRep =
+projectTests = %5B%0A     
  %7B%0A      id: %221%22
@@ -2725,33 +2725,37 @@
     %7B%0A      
+  
 id: %22
-1
+2
 %22,%0A
+  
       name: 
@@ -2759,48 +2759,59 @@
 e: %22
-test suite%22,%0A      test
+first test%22,%0A        command
 s: %5B
+%5D
 %0A   
+   %7D,%0A
      
+ 
 %7B%0A
-  
     
@@ -2811,33 +2811,33 @@
  %7B%0A        id: %22
-2
+3
 %22,%0A          nam
@@ -2831,36 +2831,36 @@
         
- 
- 
 name: %22
-first
+second
  test%22
+,
 %0A       
@@ -2864,25 +2864,56 @@
     
-%7D,%0A        %7B%0A    
+commands: %5B%5D%0A      %7D%0A    %5D;%0A    const jsRep = %7B%0A
     
@@ -2911,33 +2911,33 @@
  = %7B%0A      id: %22
-3
+1
 %22,%0A          nam
@@ -2933,48 +2933,50 @@
     
-   
- 
 name: %22
-second test%22%0A        %7D%0A      
+test suite%22,%0A      tests: %5B%222%22, %223%22
 %5D%0A  
@@ -3008,32 +3008,46 @@
 ite.fromJS(jsRep
+, projectTests
 );%0A    expect(su

load tests as well