function capitalizeName(name){
  return name.toUpperCase();
}

---

describe("TestStringUtilities", function() {
      it("konwertuje na wielkie litery", function() {
          var str = "albert";
          expect(capitalizeName(str)).toEqual("ALBERT");
      });
}); 

---

<script src="src/bigfatjavascriptcode.js"></script>
<script src="spec/test.spec.js"></script>

---

it("może obsługiwać undefined", function() {
    var str= undefined;
    expect(capitalizeName(str)).toEqual(undefined);
});

---

function capitalizeName(name){
  if(name){
    return name.toUpperCase();
  }
}

---

describe("TestStringUtilities", function() {
      it("konwertuje na wielkie litery", function() {
          var str = "albert";
          expect(capitalizeName(str)).toEqual("ALBERT");
      });
      it("can handle undefined", function() {
          var str= undefined;
          expect(capitalizeName(str)).toEqual(undefined);
      });
});

---

describe("konfigurator atrapy", function() {
  var cofigurator = null;
  var responseJSON = {};

  beforeEach(function() {
    configurator = {
      submitPOSTRequest: function(payload) {
        // To jest atrapa usługi, która ostatecznie zostanie zastąpiona przez prawdziwą usługę 
        console.log(payload);
        return {"status": "200"};
      }
    };
    spyOn(configurator, 'submitPOSTRequest').and.returnValue
      ({"status": "200"});
    configurator.submitPOSTRequest({
      "port":"8000",
      "client-encoding":"UTF-8"
    });
  });

  it("szpieg został wywołany", function() {
    expect(configurator.submitPOSTRequest).toHaveBeenCalled();
  });

  it("argumenty wywołania szpiega są śledzone", function() {
    expect(configurator.submitPOSTRequest).toHaveBeenCalledWith(
      {"port":"8000", "client-encoding":"UTF-8"});
  });
});

---

function engageGear(gear){
  if(gear==="R"){ console.log ("Cofanie");}
  if(gear==="D"){ console.log ("Jazda do przodu");}
  if(gear==="N"){ console.log ("Bieg neutralny/Parkowanie");}
  throw new Error("Nieprawidłowy stan skrzyni biegów");
}
try
{
  engageGear("R"); // Cofanie
  engageGear("P"); // Nieprawidłowy stan skrzyni biegów
}
catch(e){
  console.log(e.message);
}

---

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Nasz test</title>
  <script type="text/javascript">
  function engageGear(gear){
    if(gear==="R"){ console.log ("Cofanie");}
    if(gear==="D"){ console.log ("Jazda do przodu");}
    if(gear==="N"){ console.log ("Bieg neutralny/Parkowanie");}
    throw new Error("Nieprawidłowy stan skrzyni biegów");
  }
  try
  {
    engageGear("R"); // Cofanie
    engageGear("P"); // Nieprawidłowy stan skrzyni biegów
  }
  catch(e){
    console.log(e.message);
  }
  </script>
</head>
<body>
</body>
</html>

---


