본문 바로가기

전체 글164

Array().join(" ") & Object & Property & 객체의 property로 담겨있는 function이 method처럼 작동 & 'in' & 객체에 property를 더하고 빼는법 & class.prototype.method() describe("Object에 관해서", function() { describe("Property에 관해서", function() { let meglomaniac; beforeEach(function() { meglomaniac = { mastermind: "Joker", henchwoman: "Harley" }; }); it("객체에 property가 존재하는지 확인합니다.", function() { expect(meglomaniac.mastermind).toBe("Joker"); }); it("객체의 property는 알파벳 대소문자를 구분합니다.", function() { expect(meglomaniac.henchwoman).toBe("Harley"); expect(meglomaniac.henc.. 2020. 1. 21.
scope & 클로저 함수(고정 값) & 함수에서 전달인자 & 함수 표현식(변수에 함수를 선언하는 방법) describe("Function에 관해서", function() { it("function을 선언하는 법을 학습합니다.", function() { function add(a, b) { return a + b; } expect(add(1, 2)).toBe(3); }); it("함수 scope에 관해서 학습합니다.", function() { let message = "Outer"; function getMessage() { return message; } function overrideMessage() { let message = "Inner"; return message; } expect(getMessage()).toBe("Outer"); expect(overrideMessage()).toBe("Inne.. 2020. 1. 21.
toEqual()는 == && toBe()는 ===, 대상의 'type' describe("Expect에 관해서", function() { // 지금 부터 expect의 사용법을 학습합니다. // 우리가 테스트 해볼 값이 true인지를 검사합니다. it("테스트 하고 싶은 값이 true 인지를 검사합니다.", function() { expect(true).toBeTruthy(); // 이 코드는 우리가 기대하는 값이 true이여야 한다는 뜻입니다. // expect(테스트 하고 싶은 값) }); // 테스트를 하기위해서는 우리가 실제 값이 우리가 원하는 값과 같은지 비교하여야합니다. it("두 값의 일치 여부를 검사합니다.", function() { let expectedValue = 2; let actualValue = 1 + 1; expect(actualValue === .. 2020. 1. 21.
Array & 주소값 & slice & typeof describe("Array에 관해서", function() { // 아래의 모든 test들을 통과하여야합니다 it("Array의 기본을 확인합니다.", function() { let emptyArray = []; // Array에 typeof를 적용하면 어떤 값을 얻을 수 있을까요? expect(typeof emptyArray).toBe("object"); expect(emptyArray.length).toBe(0); let multiTypeArray = [ 0, 1, "two", function() { return 3; }, { value1: 4, value2: 5 }, [6, 7] ]; expect(multiTypeArray[0]).toBe(0); expect(multiTypeArray[2]).to.. 2020. 1. 21.