From 60986de9422c640984de22df365478f10b98aa8f Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 09:15:42 -0800 Subject: [PATCH 01/63] docs: refactoring to subsections --- docs-source/forms-source/form4-doc/_main.md | 2 +- .../_main.md} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename docs-source/forms-source/form4-doc/{pointOfSaleDataUtils.md => pointOfSaleDataUtils/_main.md} (99%) diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 2d56ed2..88b0b10 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -17,6 +17,6 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (section-main "./why.md") (section-main "./hints.md") (section-main "./app.md") - (section-main "./pointOfSaleDataUtils.md") + (section-main "./pointOfSaleDataUtils/_main.md") ) /bl--> \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md similarity index 99% rename from docs-source/forms-source/form4-doc/pointOfSaleDataUtils.md rename to docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md index a784e09..73ae07f 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md @@ -6,11 +6,11 @@ ### Important Files -Test File: +Test File: > test/[4_test-dummy-form.test.js](../test/4_test-dummy-form.test.js) -File Under Test: +File Under Test: > jsforms-source/4_test-dummy-form/pos-transaction-services/[pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) From 9173f2d8667851547916994cff929549f103c346 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 09:21:56 -0800 Subject: [PATCH 02/63] docs: refactoring form4 --- .../form4-doc/pointOfSaleDataUtils/_main.md | 18 +++--------------- .../pointOfSaleDataUtils/importantFiles.md | 17 +++++++++++++++++ docs/TEST-DUMMY-FORM.md | 4 ++-- 3 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md index 73ae07f..23c4bb0 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md @@ -3,21 +3,9 @@ (title "Point of Sale Data Utilities") ) /bl--> - -### Important Files - -Test File: - -> test/[4_test-dummy-form.test.js](../test/4_test-dummy-form.test.js) - -File Under Test: - -> jsforms-source/4_test-dummy-form/pos-transaction-services/[pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) - -Helpers File: - -> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) - + ### Get product count by sale You will be testing that the `getProductCountBySale` works correctly. (Don't worry it does, but you have to prove it.) diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md new file mode 100644 index 0000000..384b3da --- /dev/null +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md @@ -0,0 +1,17 @@ + + +Test File: + +> test/[4_test-dummy-form.test.js](../test/4_test-dummy-form.test.js) + +File Under Test: + +> jsforms-source/4_test-dummy-form/pos-transaction-services/[pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) + +Helpers File: + +> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 56198ca..48968e5 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -165,7 +165,7 @@ TBD ## Point of Sale Data Utilities ## -### Important Files +### Important Files ### Test File: @@ -178,7 +178,7 @@ File Under Test: Helpers File: > test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) - + ### Get product count by sale You will be testing that the `getProductCountBySale` works correctly. (Don't worry it does, but you have to prove it.) From e8f1bfc70efab9029906b33335594a5693f53a7c Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 10:18:06 -0800 Subject: [PATCH 03/63] docs: working on form4 --- .../form4-doc/pointOfSaleDataUtils/_main.md | 454 +------------- .../getProductCountBySale.md | 555 ++++++++++++++++++ docs/TEST-DUMMY-FORM.md | 128 +++- 3 files changed, 670 insertions(+), 467 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md index 23c4bb0..b484ecf 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md @@ -5,458 +5,6 @@ /bl--> -### Get product count by sale - -You will be testing that the `getProductCountBySale` works correctly. (Don't worry it does, but you have to prove it.) - -There are a series of tests already layed out for you. We will approach each one individually. - -#### It returns an empty object for sale counts if no sale data exists - -This first test ensures that the `getProductCountBySale` function works properly if you give it nothing to do. So when you give it an empty array, it should return an empty object. - -The process you will follow is: - -1. Enable the test -2. Add guide comments - 1. Act - 2. Assert -3. Implement the act -4. Implement the assert -5. Remove Guide comments - -##### Enable the test - -Each test case is defined by an `it` block. The format for an it block is as follows - -```javascript - it('has a description here', testFunction); -``` - -The description is the name of the test. The test function, can be a function name, a function expression, or an arrow function expression. For this exorcise use the arrow function expression like bellow. - -```javascript - it('does some thing', () => {}); -``` - -This step will cause the test to pass. However it is a false positive as this test does nothing. - -
Hints - -The `it` already exists on line 51, all you need to do is add the arrow function expression. The description is the name of the parent section without then "It": - -> returns an empty object for sale counts if no sale data exists - -
Code - -**Example** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => {}); -``` - -
- -
- -##### Add Guiding Comments - -To the arrow function expression, you will add the following comments - -```javascript -// Act -// Assert -``` - -These represent the logical steps of testing such a simple thing. We will then use the comments to implement the test. - -
Hints - -You will need to add two line brakes to the arrow function expression between the curly braces. - -
Code - -**Example** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => { - // Act - // Assert - }); -``` - -
- -
- -##### Implement the act - -The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty array. - -
Hints - -You need to make a call the the `getProductCountBySale` method with an empty array and set a variable to that result. - -
Code - -**Example** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => { - // Act - let result = pointOfSaleDataUtilities.getProductCountBySale([]); - // Assert - }); -``` - -
- -
- -##### Implement the Assert - -Assert refers to the need to validate that the code does what we expect it to do. It often uses a keyword `assert`. For our tests they will. - -Now you need to validate that the result to the call of `getProductCountBySale` returns an empty object. - -> Note: an empty object in JavaScript is an object with no properties or methods. i.e `{}` - -You will use the `assert.deepEqual` method to prove this. This method has the following signature: - -```javascript -assert.deepEqual(actualResult, expectedResult) -``` - -
Hints - -The expected result is `{}`. - -
Code - -**Example** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => { - // Act - let ? = pointOfSaleDataUtilities.getProductCountBySale([]); - // Assert - assert.deepEqual(?, {}); - }); -``` - -
- -
- -##### Remove Guide comments - -Now delete then comments as they provide no extra value. - -
Hints - -Delete the comment lines - -
Code - -**Example 1 (`let`)** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => { - let ? = pointOfSaleDataUtilities.getProductCountBySale([]); - - assert.deepEqual(?, {}); - }); -``` - -**Example 2 (`var`)** - -```javascript - it('returns an empty object for sale counts if no sale data exists', () => { - var ? = pointOfSaleDataUtilities.getProductCountBySale([]); - - assert.deepEqual(?, {}); - }); -``` - -
- -
- -### It returns an object with a single count of 1 when only one item, quantity 1 was purchased - -The next test is to test what happens when a only one item is passed to the `getProductCountBySale` method and it is a sale with only one item sold of that product. - -It will then return an item with a property equal to the product ID with an integer value equal to that item's quantity. So if `productId: 42` was passed you should get an item that looks like: - -```javascript -{ - [42]: 1 -} -``` - -The process you will follow is: - -1. Enable the test -2. Add guide comments - 1. Arrange - 2. Act - 3. Assert -3. Implement the arrange -4. Implement the act -5. Implement the assert -6. Remove Guide comments - -This will be the last test where we dive into each of these steps in detail. - -##### Enable the test - -Each test case is defined by an `it` block. Enabling the test will cause the test to pass. However it is a false positive as this test does nothing. - -
Hints - -You did this once already in the last test. - -The `it` already exists just below the last test, all you need to do is add the arrow function expression. The description is the name of the parent section without then "It": - -> returns an object with a single count of 1 when only one item, quantity 1 was purchased - -
Code - -**Example** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => {}); -``` - -
- -
- -##### Add guide comments - -You will add the following three comments to the arrow function expression. - -```javascript -// Arrange -// Act -// Assert -``` - -> Note: these comments are often referred to as "The Triple A" comments. - -
Hints - -You will need to add two line brakes to the arrow function expression between the curly braces. - -
Code - -**Example** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - // Act - // Assert - }); -``` - -
- -
- -##### Implement the arrange - -Arrange refers to the need to do some setup before we act. - -In this test we need to create a transaction record with the transaction status of Sale, and a quantity of 1. Write the code beneath the comment. - -You will use the helper function `buildTransactionRecord` which has the following signature. - -> `buildTransactionRecord(productId, transactionStatus, quantity)` - -The `productId` is a integer number intended to identify then product. In this test it can be any valid integer, though probably should keep it positive. - -The `transactionStatus` is a integer number that represents Sale or Return. You have a helper `transactionStatuses`. In this test you will use the value `transactionStatuses.Sale`. - -The `quantity` is a positive integer number that represents the amount sold. - -
Hints - -You will create a variable and assign it to the value returned from the `buildTransactionRecord` function call. - -
Code - -**Example 1 (`let`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); - // Act - // Assert - }); -``` - -**Example 2 (`var`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); - // Act - // Assert - }); -``` - -
- -
- -##### Implement the act - -The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty that has the variable created during the arrange. - -
Hints - -You need to make a call the the `getProductCountBySale` method with an empty array and set a variable to that result. - -
Code - -**Example 1 (`let`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - // Act - let result = getProductCountBySale([?]); - // Assert - }); -``` - -**Example 2 (`var`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - // Act - var result = getProductCountBySale([?]); - // Assert - }); -``` - -
- -
- -##### Implement the assert - -Assert refers to the need to validate that the code does what we expect it to do. - -Now you need to validate that the result to the call of `getProductCountBySale` returns an object with a single count. - -The object is expected to have the following shape. - -```javascript - { - [productId]: 1 - } -``` - -The productId in this case is the value given to the first parameter of the `buildTransactionRecord` function call. - -You will use the `assert.deepEqual` method to prove this. This method has the following signature: - -```javascript -assert.deepEqual(actualResult, expectedResult) -``` - -
Hints - -You can just copy the provided object above into the assert for the expected value, and replace `productId` with the correct number. - -
Code - -**Example 1 (`let`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - // Act - let result = getProductCountBySale([transactionRecord]); - - // Assert - assert.deepEqual(result, { - [?]: 1 - }); - }); -``` - -**Example 2 (`var`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - // Arrange - var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - // Act - var result = getProductCountBySale([transactionRecord]); - - // Assert - assert.deepEqual(result, { - [?]: 1 - }); - }); -``` - -
- -
- -##### Remove Guide comments - -Now remove the comments as they serve no further purpose. - -
Hints - -Just delete them. - -
Code - -
- -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - let result = getProductCountBySale([transactionRecord]); - - assert.deepEqual(result, { - [?]: 1 - }); - }); -``` - -**Example 2 (`var`)** - -```javascript - it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { - var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - - var result = getProductCountBySale([transactionRecord]); - - assert.deepEqual(result, { - [?]: 1 - }); - }); -``` - -
- ### TBD \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md new file mode 100644 index 0000000..cedf3bc --- /dev/null +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md @@ -0,0 +1,555 @@ + +You will be testing that the `getProductCountBySale` works correctly. (Don't worry it does, but you have to prove it.) + +There are a series of tests already layed out for you. We will approach each one individually. + +#### It returns an empty object for sale counts if no sale data exists #### + +This first test ensures that the `getProductCountBySale` function works properly if you give it nothing to do. So when you give it an empty array, it should return an empty object. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Act + 2. Assert +3. Implement the act +4. Implement the assert +5. Remove Guide comments + +##### Enable the test ##### + +Each test case is defined by an `it` block. The format for an it block is as follows + +```javascript + it('has a description here', testFunction); +``` + +The description is the name of the test. The test function, can be a function name, a function expression, or an arrow function expression. For this exorcise use the arrow function expression like bellow. + +```javascript + it('does some thing', () => {}); +``` + +This step will cause the test to pass. However it is a false positive as this test does nothing. + +
Hints + +The `it` already exists on line 51, all you need to do is add the arrow function expression. The description is the name of the parent section without then "It": + +> returns an empty object for sale counts if no sale data exists + +
Code + +**Example** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => {}); +``` + +
+ +
+ +##### Add Guiding Comments ##### + +To the arrow function expression, you will add the following comments + +```javascript +// Act +// Assert +``` + +These represent the logical steps of testing such a simple thing. We will then use the comments to implement the test. + +
Hints + +You will need to add two line brakes to the arrow function expression between the curly braces. + +
Code + +**Example** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => { + // Act + // Assert + }); +``` + +
+ +
+ +##### Implement the Act ##### + +The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty array. + +
Hints + +You need to make a call the the `getProductCountBySale` method with an empty array and set a variable to that result. + +
Code + +**Example** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => { + // Act + let result = pointOfSaleDataUtilities.getProductCountBySale([]); + // Assert + }); +``` + +
+ +
+ +##### Implement the Assert ##### + +Assert refers to the need to validate that the code does what we expect it to do. It often uses a keyword `assert`. For our tests they will. + +Now you need to validate that the result to the call of `getProductCountBySale` returns an empty object. + +> Note: an empty object in JavaScript is an object with no properties or methods. i.e `{}` + +You will use the `assert.deepEqual` method to prove this. This method has the following signature: + +```javascript +assert.deepEqual(actualResult, expectedResult) +``` + +
Hints + +The expected result is `{}`. + +
Code + +**Example** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => { + // Act + let ? = pointOfSaleDataUtilities.getProductCountBySale([]); + // Assert + assert.deepEqual(?, {}); + }); +``` + +
+ +
+ +##### Remove guide comments ##### + +Now delete then comments as they provide no extra value. + +
Hints + +Delete the comment lines + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => { + let ? = pointOfSaleDataUtilities.getProductCountBySale([]); + + assert.deepEqual(?, {}); + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an empty object for sale counts if no sale data exists', () => { + var ? = pointOfSaleDataUtilities.getProductCountBySale([]); + + assert.deepEqual(?, {}); + }); +``` + +
+ +
+ +#### It returns an object with a single count of 1 when only one item, quantity 1 was purchased #### + +The next test is to test what happens when a only one item is passed to the `getProductCountBySale` method and it is a sale with only one item sold of that product. + +It will then return an item with a property equal to the product ID with an integer value equal to that item's quantity. So if `productId: 42` was passed you should get an item that looks like: + +```javascript +{ + [42]: 1 +} +``` + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +This will be the last test where we dive into each of these steps in detail. + +##### Enable the test test 2 ##### + +Each test case is defined by an `it` block. Enabling the test will cause the test to pass. However it is a false positive as this test does nothing. + +
Hints + +You did this once already in the last test. + +The `it` already exists just below the last test, all you need to do is add the arrow function expression. The description is the name of the parent section without then "It": + +> returns an object with a single count of 1 when only one item, quantity 1 was purchased + +
Code + +**Example** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => {}); +``` + +
+ +
+ +##### Add guide comments test 2 ##### + +You will add the following three comments to the arrow function expression. + +```javascript +// Arrange +// Act +// Assert +``` + +> Note: these comments are often referred to as "The Triple A" comments. + +
Hints + +You will need to add two line brakes to the arrow function expression between the curly braces. + +
Code + +**Example** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + // Act + // Assert + }); +``` + +
+ +
+ +##### Implement the Arrange test 2 ##### + +Arrange refers to the need to do some setup before we act. + +In this test we need to create a transaction record with the transaction status of Sale, and a quantity of 1. Write the code beneath the comment. + +You will use the helper function `buildTransactionRecord` which has the following signature. + +> `buildTransactionRecord(productId, transactionStatus, quantity)` + +The `productId` is a integer number intended to identify then product. In this test it can be any valid integer, though probably should keep it positive. + +The `transactionStatus` is a integer number that represents Sale or Return. You have a helper `transactionStatuses`. In this test you will use the value `transactionStatuses.Sale`. + +The `quantity` is a positive integer number that represents the amount sold. + +
Hints + +You will create a variable and assign it to the value returned from the `buildTransactionRecord` function call. + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); + // Act + // Assert + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); + // Act + // Assert + }); +``` + +
+ +
+ +##### Implement the Act test 2 ##### + +The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty that has the variable created during the arrange. + +
Hints + +You need to make a call the the `getProductCountBySale` method with an empty array and set a variable to that result. + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + // Act + let result = getProductCountBySale([?]); + // Assert + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + // Act + var result = getProductCountBySale([?]); + // Assert + }); +``` + +
+ +
+ +##### Implement the Assert test 2 ##### + +Assert refers to the need to validate that the code does what we expect it to do. + +Now you need to validate that the result to the call of `getProductCountBySale` returns an object with a single count. + +The object is expected to have the following shape. + +```javascript + { + [productId]: 1 + } +``` + +The productId in this case is the value given to the first parameter of the `buildTransactionRecord` function call. + +You will use the `assert.deepEqual` method to prove this. This method has the following signature: + +```javascript +assert.deepEqual(actualResult, expectedResult) +``` + +
Hints + +You can just copy the provided object above into the assert for the expected value, and replace `productId` with the correct number. + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + // Act + let result = getProductCountBySale([transactionRecord]); + + // Assert + assert.deepEqual(result, { + [?]: 1 + }); + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + // Arrange + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + // Act + var result = getProductCountBySale([transactionRecord]); + + // Assert + assert.deepEqual(result, { + [?]: 1 + }); + }); +``` + +
+ +
+ +##### Remove Guide comments ##### + +Now remove the comments as they serve no further purpose. + +
Hints + +Just delete them. + +
Code + +
+ +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + let result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 1 + }); + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + var result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 1 + }); + }); +``` + +
+ +#### It returns an object with a single count of 2 when only one item, quantity 2 was purchased #### + +The intent of this test is to verify that the `quantity` field of the transaction record is actually used. By writing almost the same test, but differing only in quantity, you can verify that the `quantity` is used in the result. + +So now you will create a test that looks very similar to the previous one but will use a quantity of 2. + +he process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +However, then only steps this guide will cover for this test are the "Implement" step 3, and then the rest of the code. + +##### Implement the Arrange test 3 ##### + +After enabling the tests and writing the guide comments, you need to use the `buildTransactionRecord` function just like above. The only difference is the last parameter will be a `2` instead of a `1`. + +
Hints + +Remember then signature for the `buildTransactionRecord` is `buildTransactionRecord(productId, transactionStatus, quantity)`. + +You will simply capture the result as a variable. + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + // Arrange + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + // Act + // Assert + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + // Arrange + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + // Act + // Assert + }); +``` + +
+ +
+ +##### Finish the Test ##### + +Now you have done the rest before. Fill in the "Act", the "Assert" and then delete the comments. Remember that you are verifying the value of the result object is `2`. + +
Hints + +The last two lines of this test should look almost exactly like the test above except with a `2` instead of a 1 for the object value. + +
Code + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + let result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 2 + }); + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + var result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 2 + }); + }); +``` + +
+ +
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 48968e5..1e1d9c9 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -179,13 +179,13 @@ Helpers File: > test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) -### Get product count by sale +### Get product count by sale ### You will be testing that the `getProductCountBySale` works correctly. (Don't worry it does, but you have to prove it.) There are a series of tests already layed out for you. We will approach each one individually. -#### It returns an empty object for sale counts if no sale data exists +#### It returns an empty object for sale counts if no sale data exists #### This first test ensures that the `getProductCountBySale` function works properly if you give it nothing to do. So when you give it an empty array, it should return an empty object. @@ -199,7 +199,7 @@ The process you will follow is: 4. Implement the assert 5. Remove Guide comments -##### Enable the test +##### Enable the test ##### Each test case is defined by an `it` block. The format for an it block is as follows @@ -233,7 +233,7 @@ The `it` already exists on line 51, all you need to do is add the arrow function -##### Add Guiding Comments +##### Add Guiding Comments ##### To the arrow function expression, you will add the following comments @@ -263,7 +263,7 @@ You will need to add two line brakes to the arrow function expression between th -##### Implement the act +##### Implement the Act ##### The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty array. @@ -287,7 +287,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr -##### Implement the Assert +##### Implement the Assert ##### Assert refers to the need to validate that the code does what we expect it to do. It often uses a keyword `assert`. For our tests they will. @@ -322,7 +322,7 @@ The expected result is `{}`. -##### Remove Guide comments +##### Remove guide comments ##### Now delete then comments as they provide no extra value. @@ -356,7 +356,7 @@ Delete the comment lines -### It returns an object with a single count of 1 when only one item, quantity 1 was purchased +#### It returns an object with a single count of 1 when only one item, quantity 1 was purchased #### The next test is to test what happens when a only one item is passed to the `getProductCountBySale` method and it is a sale with only one item sold of that product. @@ -382,7 +382,7 @@ The process you will follow is: This will be the last test where we dive into each of these steps in detail. -##### Enable the test +##### Enable the test test 2 ##### Each test case is defined by an `it` block. Enabling the test will cause the test to pass. However it is a false positive as this test does nothing. @@ -406,7 +406,7 @@ The `it` already exists just below the last test, all you need to do is add the -##### Add guide comments +##### Add guide comments test 2 ##### You will add the following three comments to the arrow function expression. @@ -438,7 +438,7 @@ You will need to add two line brakes to the arrow function expression between th -##### Implement the arrange +##### Implement the Arrange test 2 ##### Arrange refers to the need to do some setup before we act. @@ -486,7 +486,7 @@ You will create a variable and assign it to the value returned from the `buildTr -##### Implement the act +##### Implement the Act test 2 ##### The "Act" refers to the action under test. You will need to do the thing the test is trying to test. So with this test you are trying to test what will happen when `getProductCountBySale` method on the `pointOfSaleDataUtilities` object is called with an empty that has the variable created during the arrange. @@ -526,7 +526,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr -##### Implement the assert +##### Implement the Assert test 2 ##### Assert refers to the need to validate that the code does what we expect it to do. @@ -592,7 +592,7 @@ You can just copy the provided object above into the assert for the expected val -##### Remove Guide comments +##### Remove Guide comments ##### Now remove the comments as they serve no further purpose. @@ -632,6 +632,106 @@ Just delete them. +#### It returns an object with a single count of 2 when only one item, quantity 2 was purchased #### + +The intent of this test is to verify that the `quantity` field of the transaction record is actually used. By writing almost the same test, but differing only in quantity, you can verify that the `quantity` is used in the result. + +So now you will create a test that looks very similar to the previous one but will use a quantity of 2. + +he process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +However, then only steps this guide will cover for this test are the "Implement" step 3, and then the rest of the code. + +##### Implement the Arrange test 3 ##### + +After enabling the tests and writing the guide comments, you need to use the `buildTransactionRecord` function just like above. The only difference is the last parameter will be a `2` instead of a `1`. + +
Hints + +Remember then signature for the `buildTransactionRecord` is `buildTransactionRecord(productId, transactionStatus, quantity)`. + +You will simply capture the result as a variable. + +
Code + +**Example 1 (`let`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + // Arrange + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + // Act + // Assert + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + // Arrange + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + // Act + // Assert + }); +``` + +
+ +
+ +##### Finish the Test ##### + +Now you have done the rest before. Fill in the "Act", the "Assert" and then delete the comments. Remember that you are verifying the value of the result object is `2`. + +
Hints + +The last two lines of this test should look almost exactly like the test above except with a `2` instead of a 1 for the object value. + +
Code + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + let result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 2 + }); + }); +``` + +**Example 2 (`var`)** + +```javascript + it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { + var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); + + var result = getProductCountBySale([transactionRecord]); + + assert.deepEqual(result, { + [?]: 2 + }); + }); +``` + +
+ +
+ ### TBD From 250ad104eaf1932c6a845857dc1dc885e0be87a8 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 11:28:23 -0800 Subject: [PATCH 04/63] docs: getProductCountBySale for form4 --- .../getProductCountBySale.md | 273 +++++++++++++++++- docs/TEST-DUMMY-FORM.md | 273 +++++++++++++++++- 2 files changed, 544 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md index cedf3bc..53960c4 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md @@ -460,7 +460,7 @@ The intent of this test is to verify that the `quantity` field of the transactio So now you will create a test that looks very similar to the previous one but will use a quantity of 2. -he process you will follow is: +The process you will follow is: 1. Enable the test 2. Add guide comments @@ -552,4 +552,275 @@ The last two lines of this test should look almost exactly like the test above e + + +#### It returns an object with a two counts of 1 when two transactions of 1 qty each are passed #### + +Now you will be seeing what happens when you pass 2 different transaction records to the `getProductCountBySale` each one with a different product IDs. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +From this point on we will not cover any of the individual steps, but focus on the outcome of following those steps. Also for simplicity, this guide will only show examples for `let` variable statements as they are slightly more dependable. + +What you are going to want to do, is to modify the the test such that you create 2 different transactions records using the `buildTransactionRecord` function. + +> Make sure these have different product IDs. + +So given: + +Product ID 314 +and +Product ID 42 + +then the result should look like: + +```javascript +{ + [314]: 1 + [42]: 1 +} +``` + +
Hints + +All three parts of the test that change. In the "Arrange" you will want to create the two transactions records. + +In the "Act" you will pass both of the transaction records to the `getProductCountBySale` function. + +In the "Assert" you want to ensure the resulting object has those record quantities. + +
Code + +**Example 1 (explicit variables)** + +```javascript + it('returns an object with a two counts of 1 when two transactions of 1 qty each are passed', () => { + let transactionP1 = buildTransactionRecord(?, transactionStatuses.Sale, 1); + let transactionP2 = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + let result = getProductCountBySale([ + transactionP1, + transactionP2 + ]); + + assert.deepEqual(result, { + [?]: 1 + [?]: 1 + }); + }); +``` + +**Example 2 (implicit variables)** + +```javascript + it('returns an object with a two counts of 1 when two transactions of 1 qty each are passed', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ]; + + let result = getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: 1 + [?]: 1 + }); + }); +``` + +
+ +
+ +#### It returns an object with a two counts when 4 transactions of two different items are passed #### + +The intent of this test is to see if the `getProductCountBySale` function will sum quantities across two different products. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will need to create 2 different products, each with two transaction records. The test does not specify what the quantities are, so you will have to determine that. + +> **NOTE:** Make sure that the totals of the quantities across both products are different, or else you do not know if the function is summing one and duplicating it. + +> **GUIDE:** It would be helpful to create a variable that holds each product ID as you will need that in at least three different places. Also this variable will help make your code more readable. + +
Hints + +Again all the portions of the test have changed. + +In the "Arrange" you will need to create four different transaction records across two different product IDs. You will need to ensure that the totals of the `quantities` across the products are different. + +In the "Act", you will be passing all four transaction records to the `getProductCountBySale` function. + +In the "Assert" you will verify that then resulting object has only the two product IDs passed and it has the correct summation of their quantities. + +
Code + +**Example 1 (explicit variables)** + +```javascript + it('returns an object with a two counts when 4 transactions of two different items are passed', () => { + let product1 = ?; // ID for product 1 + let product2 = ?; // ID for product 2 + + let transaction1A = buildTransactionRecord(product1, transactionStatuses.Sale, ?); + let transaction1B = buildTransactionRecord(product1, transactionStatuses.Sale, ?); + let transaction2A = buildTransactionRecord(product2, transactionStatuses.Sale, ?); + let transaction2B = buildTransactionRecord(product2, transactionStatuses.Sale, ?); + + let result = getProductCountBySale([ + transaction1A, + transaction2A, + transaction1B, + transaction2B + ]); + + expect.deepEqual(result, { + [product1]: ? + [product2]: ? + }); + }); +``` + +**Example 1 (implicit variables)** + +```javascript + it('returns an object with a two counts when 4 transactions of two different items are passed', () => { + let product1 = ?; // ID for product 1 + let product2 = ?; // ID for product 2 + + let transactions = [ + buildTransactionRecord(product1, transactionStatuses.Sale, ?), + buildTransactionRecord(product2, transactionStatuses.Sale, ?), + buildTransactionRecord(product1, transactionStatuses.Sale, ?), + buildTransactionRecord(product2, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale(transactions); + + expect.deepEqual(result, { + [product1]: ? + [product2]: ? + }); + }); +``` + +
+ +
+ +#### It returns counts only for sales, ignoring returns #### + +The last test of the `getProductCountBySale` function is to ensure that it does not count returns. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will need at least 2 transaction records. One that is a Sale and one that is a Return, they can have the same product ID or different ones. + +You will need to use `transactionStatuses.Return` to set the type for the return transaction. + +
Hints + +In the "Arrange" you will need to create both a Sale and a Return. + +
Code + +**Example 1 (explicit, diff IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let returnTransaction = buildTransactionRecord(?, transactionStatuses.Return, ?); + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [?]: ? + }); + }); +``` + +**Example 2 (explicit, same IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let productId = ?; + let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); + let returnTransaction = buildTransactionRecord(productId, transactionStatuses.Return, ?); + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [productId]: ? + }); + }); +``` + +**Example 3 (implicit, diff IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: ? + }); + }); +``` + +**Example 4 (implicit, same IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let productId = ?; + let transactions = [ + buildTransactionRecord(productId, transactionStatuses.Return, ?), + buildTransactionRecord(productId, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [productId]: ? + }); + }); +``` + +
+
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 1e1d9c9..448b83b 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -638,7 +638,7 @@ The intent of this test is to verify that the `quantity` field of the transactio So now you will create a test that looks very similar to the previous one but will use a quantity of 2. -he process you will follow is: +The process you will follow is: 1. Enable the test 2. Add guide comments @@ -730,6 +730,277 @@ The last two lines of this test should look almost exactly like the test above e + + +#### It returns an object with a two counts of 1 when two transactions of 1 qty each are passed #### + +Now you will be seeing what happens when you pass 2 different transaction records to the `getProductCountBySale` each one with a different product IDs. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +From this point on we will not cover any of the individual steps, but focus on the outcome of following those steps. Also for simplicity, this guide will only show examples for `let` variable statements as they are slightly more dependable. + +What you are going to want to do, is to modify the the test such that you create 2 different transactions records using the `buildTransactionRecord` function. + +> Make sure these have different product IDs. + +So given: + +Product ID 314 +and +Product ID 42 + +then the result should look like: + +```javascript +{ + [314]: 1 + [42]: 1 +} +``` + +
Hints + +All three parts of the test that change. In the "Arrange" you will want to create the two transactions records. + +In the "Act" you will pass both of the transaction records to the `getProductCountBySale` function. + +In the "Assert" you want to ensure the resulting object has those record quantities. + +
Code + +**Example 1 (explicit variables)** + +```javascript + it('returns an object with a two counts of 1 when two transactions of 1 qty each are passed', () => { + let transactionP1 = buildTransactionRecord(?, transactionStatuses.Sale, 1); + let transactionP2 = buildTransactionRecord(?, transactionStatuses.Sale, 1); + + let result = getProductCountBySale([ + transactionP1, + transactionP2 + ]); + + assert.deepEqual(result, { + [?]: 1 + [?]: 1 + }); + }); +``` + +**Example 2 (implicit variables)** + +```javascript + it('returns an object with a two counts of 1 when two transactions of 1 qty each are passed', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ]; + + let result = getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: 1 + [?]: 1 + }); + }); +``` + +
+ +
+ +#### It returns an object with a two counts when 4 transactions of two different items are passed #### + +The intent of this test is to see if the `getProductCountBySale` function will sum quantities across two different products. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will need to create 2 different products, each with two transaction records. The test does not specify what the quantities are, so you will have to determine that. + +> **NOTE:** Make sure that the totals of the quantities across both products are different, or else you do not know if the function is summing one and duplicating it. + +> **GUIDE:** It would be helpful to create a variable that holds each product ID as you will need that in at least three different places. Also this variable will help make your code more readable. + +
Hints + +Again all the portions of the test have changed. + +In the "Arrange" you will need to create four different transaction records across two different product IDs. You will need to ensure that the totals of the `quantities` across the products are different. + +In the "Act", you will be passing all four transaction records to the `getProductCountBySale` function. + +In the "Assert" you will verify that then resulting object has only the two product IDs passed and it has the correct summation of their quantities. + +
Code + +**Example 1 (explicit variables)** + +```javascript + it('returns an object with a two counts when 4 transactions of two different items are passed', () => { + let product1 = ?; // ID for product 1 + let product2 = ?; // ID for product 2 + + let transaction1A = buildTransactionRecord(product1, transactionStatuses.Sale, ?); + let transaction1B = buildTransactionRecord(product1, transactionStatuses.Sale, ?); + let transaction2A = buildTransactionRecord(product2, transactionStatuses.Sale, ?); + let transaction2B = buildTransactionRecord(product2, transactionStatuses.Sale, ?); + + let result = getProductCountBySale([ + transaction1A, + transaction2A, + transaction1B, + transaction2B + ]); + + expect.deepEqual(result, { + [product1]: ? + [product2]: ? + }); + }); +``` + +**Example 1 (implicit variables)** + +```javascript + it('returns an object with a two counts when 4 transactions of two different items are passed', () => { + let product1 = ?; // ID for product 1 + let product2 = ?; // ID for product 2 + + let transactions = [ + buildTransactionRecord(product1, transactionStatuses.Sale, ?), + buildTransactionRecord(product2, transactionStatuses.Sale, ?), + buildTransactionRecord(product1, transactionStatuses.Sale, ?), + buildTransactionRecord(product2, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale(transactions); + + expect.deepEqual(result, { + [product1]: ? + [product2]: ? + }); + }); +``` + +
+ +
+ +#### It returns counts only for sales, ignoring returns #### + +The last test of the `getProductCountBySale` function is to ensure that it does not count returns. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will need at least 2 transaction records. One that is a Sale and one that is a Return, they can have the same product ID or different ones. + +You will need to use `transactionStatuses.Return` to set the type for the return transaction. + +
Hints + +In the "Arrange" you will need to create both a Sale and a Return. + +
Code + +**Example 1 (explicit, diff IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let returnTransaction = buildTransactionRecord(?, transactionStatuses.Return, ?); + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [?]: ? + }); + }); +``` + +**Example 2 (explicit, same IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let productId = ?; + let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); + let returnTransaction = buildTransactionRecord(productId, transactionStatuses.Return, ?); + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [productId]: ? + }); + }); +``` + +**Example 3 (implicit, diff IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: ? + }); + }); +``` + +**Example 4 (implicit, same IDs)** + +```javascript + it('returns counts only for sales, ignoring returns', () => { + let productId = ?; + let transactions = [ + buildTransactionRecord(productId, transactionStatuses.Return, ?), + buildTransactionRecord(productId, transactionStatuses.Sale, ?), + ]; + + let result = getProductCountBySale([returnTransaction, saleTransaction]); + + assert.deepEqual(result, { + [productId]: ? + }); + }); +``` + +
+
### TBD From 57a4d1b6b0ad4f99b1dab4a48ea63182fb992860 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 12:23:09 -0800 Subject: [PATCH 05/63] docs: fixed calls to getProductCountBySale --- .../getProductCountBySale.md | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md index 53960c4..57467c3 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountBySale.md @@ -326,7 +326,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - let result = getProductCountBySale([?]); + let result = pointOfSaleDataUtilities.getProductCountBySale([?]); // Assert }); ``` @@ -339,7 +339,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - var result = getProductCountBySale([?]); + var result = pointOfSaleDataUtilities.getProductCountBySale([?]); // Assert }); ``` @@ -384,7 +384,7 @@ You can just copy the provided object above into the assert for the expected val let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); // Assert assert.deepEqual(result, { @@ -401,7 +401,7 @@ You can just copy the provided object above into the assert for the expected val var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); // Assert assert.deepEqual(result, { @@ -430,7 +430,7 @@ Just delete them. it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 1 @@ -444,7 +444,7 @@ Just delete them. it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 1 @@ -528,7 +528,7 @@ The last two lines of this test should look almost exactly like the test above e it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 2 @@ -542,7 +542,7 @@ The last two lines of this test should look almost exactly like the test above e it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 2 @@ -595,7 +595,7 @@ then the result should look like: All three parts of the test that change. In the "Arrange" you will want to create the two transactions records. -In the "Act" you will pass both of the transaction records to the `getProductCountBySale` function. +In the "Act" you will pass both of the transaction records to the `getProductCountBySale` method. In the "Assert" you want to ensure the resulting object has those record quantities. @@ -608,7 +608,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit let transactionP1 = buildTransactionRecord(?, transactionStatuses.Sale, 1); let transactionP2 = buildTransactionRecord(?, transactionStatuses.Sale, 1); - let result = getProductCountBySale([ + let result = pointOfSaleDataUtilities.getProductCountBySale([ transactionP1, transactionP2 ]); @@ -629,7 +629,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit buildTransactionRecord(?, transactionStatuses.Sale, 1) ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); assert.deepEqual(result, { [?]: 1 @@ -644,7 +644,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit #### It returns an object with a two counts when 4 transactions of two different items are passed #### -The intent of this test is to see if the `getProductCountBySale` function will sum quantities across two different products. +The intent of this test is to see if the `getProductCountBySale` method will sum quantities across two different products. The process you will follow is: @@ -670,7 +670,7 @@ Again all the portions of the test have changed. In the "Arrange" you will need to create four different transaction records across two different product IDs. You will need to ensure that the totals of the `quantities` across the products are different. -In the "Act", you will be passing all four transaction records to the `getProductCountBySale` function. +In the "Act", you will be passing all four transaction records to the `getProductCountBySale` method. In the "Assert" you will verify that then resulting object has only the two product IDs passed and it has the correct summation of their quantities. @@ -688,7 +688,7 @@ In the "Assert" you will verify that then resulting object has only the two prod let transaction2A = buildTransactionRecord(product2, transactionStatuses.Sale, ?); let transaction2B = buildTransactionRecord(product2, transactionStatuses.Sale, ?); - let result = getProductCountBySale([ + let result = pointOfSaleDataUtilities.getProductCountBySale([ transaction1A, transaction2A, transaction1B, @@ -716,7 +716,7 @@ In the "Assert" you will verify that then resulting object has only the two prod buildTransactionRecord(product2, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); expect.deepEqual(result, { [product1]: ? @@ -731,7 +731,7 @@ In the "Assert" you will verify that then resulting object has only the two prod #### It returns counts only for sales, ignoring returns #### -The last test of the `getProductCountBySale` function is to ensure that it does not count returns. +The last test of the `getProductCountBySale` method is to ensure that it does not count returns. The process you will follow is: @@ -762,7 +762,7 @@ In the "Arrange" you will need to create both a Sale and a Return. let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); let returnTransaction = buildTransactionRecord(?, transactionStatuses.Return, ?); - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [?]: ? @@ -778,7 +778,7 @@ In the "Arrange" you will need to create both a Sale and a Return. let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); let returnTransaction = buildTransactionRecord(productId, transactionStatuses.Return, ?); - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [productId]: ? @@ -795,7 +795,7 @@ In the "Arrange" you will need to create both a Sale and a Return. buildTransactionRecord(?, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); assert.deepEqual(result, { [?]: ? @@ -813,7 +813,7 @@ In the "Arrange" you will need to create both a Sale and a Return. buildTransactionRecord(productId, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [productId]: ? From f34259faa873be6c7bb28709b67dfc2c766d7281 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 12:39:46 -0800 Subject: [PATCH 06/63] docs: finished getProductCountByReturn for form4 --- docs-source/forms-source/form4-doc/_main.md | 4 +- .../getProductCountByReturn/_main.md | 8 + .../getProductCountByReturn/counts.md | 155 ++++++++++++++ .../form4-doc/pointOfSaleDataUtils/_main.md | 3 +- docs/TEST-DUMMY-FORM.md | 199 ++++++++++++++++-- 5 files changed, 345 insertions(+), 24 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md create mode 100644 docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 88b0b10..87da8f3 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -18,5 +18,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (section-main "./hints.md") (section-main "./app.md") (section-main "./pointOfSaleDataUtils/_main.md") + (section-main "./getProductCountByReturn/_main.md") ) -/bl--> \ No newline at end of file +/bl--> +## TDB ## \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md b/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md new file mode 100644 index 0000000..beb2b4c --- /dev/null +++ b/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md b/docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md new file mode 100644 index 0000000..112c10d --- /dev/null +++ b/docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md @@ -0,0 +1,155 @@ + + +There is only one test to this section. The reason is if you look at the file [pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) you will see that the only difference between `getProductCountBySale` and `getProductCountByReturn` is a value passed to a second parameter of a method called underneath. So in regard to returns we just need to prove that the function can count them. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will want to create 2 returns, and a third for a sale. + +
Hints + +In the "Arrange" you will be creating 3 different transaction reports. Two will be returns and the third will be for a sale. You can choose, if you want any of these to share IDs. + +
Code + +**Example (explicit, diff ids)** + +```javascript + it('returns with counts only for return transactions', () => { + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(?, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(?, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [?]: ?, + [?]: ?, + }); + }); +``` + +**Example (explicit, returns share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let returnProduct = ?; + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(returnProduct, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(returnProduct, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [returnProduct]: ?, + }); + }); +``` + +**Example (explict, all share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let productId = ?; + let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(productId, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(productId, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [productId]: ?, + }); + }); +``` + +**Example (implicit, diff ids)** + +```javascript + it('returns with counts only for return transactions', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + buildTransactionRecord(?, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: ?, + [?]: ?, + }); + }); +``` + +**Example (implicit, returns share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let returnProduct = ?; + let transactions = [ + buildTransactionRecord(returnProduct, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + buildTransactionRecord(returnProduct, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); + + assert.deepEqual(result, { + [returnProduct]: ?, + }); + }); +``` + +**Example (implicit, all share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let productId = ?; + let transactions = [ + buildTransactionRecord(productId, transactionStatuses.Return, ?), + buildTransactionRecord(productId, transactionStatuses.Sale, ?), + buildTransactionRecord(productId, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [productId]: ?, + }); + }); +``` + +
+ +
\ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md index b484ecf..f9e4b36 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md @@ -6,5 +6,4 @@ -### TBD \ No newline at end of file +/bl--> \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 448b83b..57a4b7f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -16,6 +16,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy - [Section 2: A word about hints](#user-content-a-word-about-hints) - [Section 3: The application under test](#user-content-the-application-under-test) - [Section 4: Point of Sale Data Utilities](#user-content-point-of-sale-data-utilities) +- [Section 5: Get Product Count by Return Status](#user-content-get-product-count-by-return-status) ## Why would I write tests for code I know works? ## @@ -504,7 +505,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr let ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - let result = getProductCountBySale([?]); + let result = pointOfSaleDataUtilities.getProductCountBySale([?]); // Assert }); ``` @@ -517,7 +518,7 @@ You need to make a call the the `getProductCountBySale` method with an empty arr var ? = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - var result = getProductCountBySale([?]); + var result = pointOfSaleDataUtilities.getProductCountBySale([?]); // Assert }); ``` @@ -562,7 +563,7 @@ You can just copy the provided object above into the assert for the expected val let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); // Assert assert.deepEqual(result, { @@ -579,7 +580,7 @@ You can just copy the provided object above into the assert for the expected val var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); // Act - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); // Assert assert.deepEqual(result, { @@ -608,7 +609,7 @@ Just delete them. it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 1 @@ -622,7 +623,7 @@ Just delete them. it('returns an object with a single count of 1 when only one item, quantity 1 was purchased', () => { var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 1); - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 1 @@ -706,7 +707,7 @@ The last two lines of this test should look almost exactly like the test above e it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { let transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); - let result = getProductCountBySale([transactionRecord]); + let result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 2 @@ -720,7 +721,7 @@ The last two lines of this test should look almost exactly like the test above e it('returns an object with a single count of 2 when only one item, quantity 2 was purchased', () => { var transactionRecord = buildTransactionRecord(?, transactionStatuses.Sale, 2); - var result = getProductCountBySale([transactionRecord]); + var result = pointOfSaleDataUtilities.getProductCountBySale([transactionRecord]); assert.deepEqual(result, { [?]: 2 @@ -773,7 +774,7 @@ then the result should look like: All three parts of the test that change. In the "Arrange" you will want to create the two transactions records. -In the "Act" you will pass both of the transaction records to the `getProductCountBySale` function. +In the "Act" you will pass both of the transaction records to the `getProductCountBySale` method. In the "Assert" you want to ensure the resulting object has those record quantities. @@ -786,7 +787,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit let transactionP1 = buildTransactionRecord(?, transactionStatuses.Sale, 1); let transactionP2 = buildTransactionRecord(?, transactionStatuses.Sale, 1); - let result = getProductCountBySale([ + let result = pointOfSaleDataUtilities.getProductCountBySale([ transactionP1, transactionP2 ]); @@ -807,7 +808,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit buildTransactionRecord(?, transactionStatuses.Sale, 1) ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); assert.deepEqual(result, { [?]: 1 @@ -822,7 +823,7 @@ In the "Assert" you want to ensure the resulting object has those record quantit #### It returns an object with a two counts when 4 transactions of two different items are passed #### -The intent of this test is to see if the `getProductCountBySale` function will sum quantities across two different products. +The intent of this test is to see if the `getProductCountBySale` method will sum quantities across two different products. The process you will follow is: @@ -848,7 +849,7 @@ Again all the portions of the test have changed. In the "Arrange" you will need to create four different transaction records across two different product IDs. You will need to ensure that the totals of the `quantities` across the products are different. -In the "Act", you will be passing all four transaction records to the `getProductCountBySale` function. +In the "Act", you will be passing all four transaction records to the `getProductCountBySale` method. In the "Assert" you will verify that then resulting object has only the two product IDs passed and it has the correct summation of their quantities. @@ -866,7 +867,7 @@ In the "Assert" you will verify that then resulting object has only the two prod let transaction2A = buildTransactionRecord(product2, transactionStatuses.Sale, ?); let transaction2B = buildTransactionRecord(product2, transactionStatuses.Sale, ?); - let result = getProductCountBySale([ + let result = pointOfSaleDataUtilities.getProductCountBySale([ transaction1A, transaction2A, transaction1B, @@ -894,7 +895,7 @@ In the "Assert" you will verify that then resulting object has only the two prod buildTransactionRecord(product2, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); expect.deepEqual(result, { [product1]: ? @@ -909,7 +910,7 @@ In the "Assert" you will verify that then resulting object has only the two prod #### It returns counts only for sales, ignoring returns #### -The last test of the `getProductCountBySale` function is to ensure that it does not count returns. +The last test of the `getProductCountBySale` method is to ensure that it does not count returns. The process you will follow is: @@ -940,7 +941,7 @@ In the "Arrange" you will need to create both a Sale and a Return. let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); let returnTransaction = buildTransactionRecord(?, transactionStatuses.Return, ?); - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [?]: ? @@ -956,7 +957,7 @@ In the "Arrange" you will need to create both a Sale and a Return. let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); let returnTransaction = buildTransactionRecord(productId, transactionStatuses.Return, ?); - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [productId]: ? @@ -973,7 +974,7 @@ In the "Arrange" you will need to create both a Sale and a Return. buildTransactionRecord(?, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale(transactions); + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); assert.deepEqual(result, { [?]: ? @@ -991,7 +992,7 @@ In the "Arrange" you will need to create both a Sale and a Return. buildTransactionRecord(productId, transactionStatuses.Sale, ?), ]; - let result = getProductCountBySale([returnTransaction, saleTransaction]); + let result = pointOfSaleDataUtilities.getProductCountBySale([returnTransaction, saleTransaction]); assert.deepEqual(result, { [productId]: ? @@ -1003,8 +1004,164 @@ In the "Arrange" you will need to create both a Sale and a Return. -### TBD +## Get Product Count by Return Status ## + +### It returns with counts only for return transactions ### + +There is only one test to this section. The reason is if you look at the file [pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) you will see that the only difference between `getProductCountBySale` and `getProductCountByReturn` is a value passed to a second parameter of a method called underneath. So in regard to returns we just need to prove that the function can count them. + +The process you will follow is: + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +You will want to create 2 returns, and a third for a sale. + +
Hints + +In the "Arrange" you will be creating 3 different transaction reports. Two will be returns and the third will be for a sale. You can choose, if you want any of these to share IDs. + +
Code + +**Example (explicit, diff ids)** + +```javascript + it('returns with counts only for return transactions', () => { + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(?, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(?, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [?]: ?, + [?]: ?, + }); + }); +``` + +**Example (explicit, returns share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let returnProduct = ?; + let saleTransaction = buildTransactionRecord(?, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(returnProduct, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(returnProduct, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [returnProduct]: ?, + }); + }); +``` + +**Example (explict, all share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let productId = ?; + let saleTransaction = buildTransactionRecord(productId, transactionStatuses.Sale, ?); + let return1 = buildTransactionRecord(productId, transactionStatuses.Return, ?); + let return2 = buildTransactionRecord(productId, transactionStatuses.Return, ?); + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [productId]: ?, + }); + }); +``` + +**Example (implicit, diff ids)** + +```javascript + it('returns with counts only for return transactions', () => { + let transactions = [ + buildTransactionRecord(?, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + buildTransactionRecord(?, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); + + assert.deepEqual(result, { + [?]: ?, + [?]: ?, + }); + }); +``` + +**Example (implicit, returns share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let returnProduct = ?; + let transactions = [ + buildTransactionRecord(returnProduct, transactionStatuses.Return, ?), + buildTransactionRecord(?, transactionStatuses.Sale, ?), + buildTransactionRecord(returnProduct, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale(transactions); + + assert.deepEqual(result, { + [returnProduct]: ?, + }); + }); +``` + +**Example (implicit, all share ID)** + +```javascript + it('returns with counts only for return transactions', () => { + let productId = ?; + let transactions = [ + buildTransactionRecord(productId, transactionStatuses.Return, ?), + buildTransactionRecord(productId, transactionStatuses.Sale, ?), + buildTransactionRecord(productId, transactionStatuses.Return, ?), + ]; + + let result = pointOfSaleDataUtilities.getProductCountBySale([ + return1, + saleTransaction, + return2, + ]); + + assert.deepEqual(result, { + [productId]: ?, + }); + }); +``` + +
+ +
+ + + +## TDB ## \ No newline at end of file From cec5e2ddd8580e060fa7bc575f76e5e2d9300632 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 12:51:08 -0800 Subject: [PATCH 07/63] docs: getProductCountByReturn in correct section --- docs-source/forms-source/form4-doc/_main.md | 1 - .../form4-doc/getProductCountByReturn/_main.md | 8 -------- .../forms-source/form4-doc/pointOfSaleDataUtils/_main.md | 1 + .../getProductCountByReturn.md} | 4 +++- docs/TEST-DUMMY-FORM.md | 6 ++---- 5 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md rename docs-source/forms-source/form4-doc/{getProductCountByReturn/counts.md => pointOfSaleDataUtils/getProductCountByReturn.md} (97%) diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 87da8f3..962b3b5 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -18,7 +18,6 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (section-main "./hints.md") (section-main "./app.md") (section-main "./pointOfSaleDataUtils/_main.md") - (section-main "./getProductCountByReturn/_main.md") ) /bl--> ## TDB ## \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md b/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md deleted file mode 100644 index beb2b4c..0000000 --- a/docs-source/forms-source/form4-doc/getProductCountByReturn/_main.md +++ /dev/null @@ -1,8 +0,0 @@ - - \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md index f9e4b36..fa94d81 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/_main.md @@ -6,4 +6,5 @@ \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountByReturn.md similarity index 97% rename from docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md rename to docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountByReturn.md index 112c10d..e62ecfb 100644 --- a/docs-source/forms-source/form4-doc/getProductCountByReturn/counts.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/getProductCountByReturn.md @@ -1,9 +1,11 @@ +#### It returns with counts only for return transactions #### + There is only one test to this section. The reason is if you look at the file [pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) you will see that the only difference between `getProductCountBySale` and `getProductCountByReturn` is a value passed to a second parameter of a method called underneath. So in regard to returns we just need to prove that the function can count them. The process you will follow is: diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 57a4b7f..60dd4c5 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -16,7 +16,6 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy - [Section 2: A word about hints](#user-content-a-word-about-hints) - [Section 3: The application under test](#user-content-the-application-under-test) - [Section 4: Point of Sale Data Utilities](#user-content-point-of-sale-data-utilities) -- [Section 5: Get Product Count by Return Status](#user-content-get-product-count-by-return-status) ## Why would I write tests for code I know works? ## @@ -1004,11 +1003,10 @@ In the "Arrange" you will need to create both a Sale and a Return. - -## Get Product Count by Return Status ## +### Get Product Count by Return Status ### -### It returns with counts only for return transactions ### +#### It returns with counts only for return transactions #### There is only one test to this section. The reason is if you look at the file [pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) you will see that the only difference between `getProductCountBySale` and `getProductCountByReturn` is a value passed to a second parameter of a method called underneath. So in regard to returns we just need to prove that the function can count them. From 6308f80ccf1ea62720cf97fc1abbf257b706cb36 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 12:57:25 -0800 Subject: [PATCH 08/63] docs: setup sales report form4 --- docs-source/forms-source/form4-doc/_main.md | 1 + docs-source/forms-source/form4-doc/salesReport/_main.md | 8 ++++++++ docs/TEST-DUMMY-FORM.md | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 docs-source/forms-source/form4-doc/salesReport/_main.md diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 962b3b5..e272931 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -18,6 +18,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (section-main "./hints.md") (section-main "./app.md") (section-main "./pointOfSaleDataUtils/_main.md") + (section-main "./salesReport/_main.md") ) /bl--> ## TDB ## \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/salesReport/_main.md b/docs-source/forms-source/form4-doc/salesReport/_main.md new file mode 100644 index 0000000..3464dfa --- /dev/null +++ b/docs-source/forms-source/form4-doc/salesReport/_main.md @@ -0,0 +1,8 @@ + + +Sales report documentation coming... \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 60dd4c5..e21d616 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -16,6 +16,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy - [Section 2: A word about hints](#user-content-a-word-about-hints) - [Section 3: The application under test](#user-content-the-application-under-test) - [Section 4: Point of Sale Data Utilities](#user-content-point-of-sale-data-utilities) +- [Section 5: Sales Report](#user-content-sales-report) ## Why would I write tests for code I know works? ## @@ -1160,6 +1161,10 @@ In the "Arrange" you will be creating 3 different transaction reports. Two will +## Sales Report ## +Sales report documentation coming... + + ## TDB ## \ No newline at end of file From 7945191e842778cd4a6a55d2dd2cc3a1f7a92461 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 17 Feb 2023 14:09:37 -0800 Subject: [PATCH 09/63] test: removed unnessessary variable --- test/4_test-dummy-form.test.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/4_test-dummy-form.test.js b/test/4_test-dummy-form.test.js index d367b47..c7e75db 100644 --- a/test/4_test-dummy-form.test.js +++ b/test/4_test-dummy-form.test.js @@ -35,19 +35,16 @@ describe('Test Dummy Form - Costume Shop Sales', function () { describe('Point of Sale Data Utilities', function () { // File being tested can be found here: // ../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js + + let pointOfSaleDataUtilities; + let transactionStatuses; - describe('get product count by sale', function () { - - let pointOfSaleDataUtilities; - let transactionStatuses; - let testData; - - beforeEach(function(){ - testData = buildSimpleTestData(); - transactionStatuses = buildTransactionStatuses(); - pointOfSaleDataUtilities = pointOfSaleDataUtilsFactory(transactionStatuses); - }); + beforeEach(function () { + transactionStatuses = buildTransactionStatuses(); + pointOfSaleDataUtilities = pointOfSaleDataUtilsFactory(transactionStatuses); + }); + describe('get product count by sale', function () { it('returns an empty object for sale counts if no sale data exists'); it('returns an object with a single count of 1 when only one item, quantity 1 was purchased'); From b888289b13997527b72b5ab2922c009896f2a70a Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 12:37:45 -0800 Subject: [PATCH 10/63] fix: Fixed a bug on transaction types --- .../pos-transaction-services/reportDataBuilder.js | 4 ++-- .../4_test-dummy-form/sales-reporter/salesReporterFactory.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js index 13baad2..b225b9f 100644 --- a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js +++ b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js @@ -1,5 +1,5 @@ // eslint-disable-next-line -function reportDataBuilderFactory() { +function reportDataBuilderFactory(transactionStatuses) { function getObjectElements(dataObject) { return Object.keys(dataObject) @@ -7,7 +7,7 @@ function reportDataBuilderFactory() { } function isSaleType(transactionType) { - return transactionType === 'Sale'; + return transactionType === transactionStatuses.Sale; } function getTotalSignMultiplier(transactionType) { diff --git a/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js b/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js index c65ef71..2bf3594 100644 --- a/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js +++ b/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js @@ -11,7 +11,7 @@ function salesReporterFactory( const transactionTypes = dataLoader.getTransactionTypes(); const pointOfSaleDataUtils = pointOfSaleDataUtilsFactory(transactionTypes); - const reportDataBuilder = reportDataBuilderFactory(pointOfSaleDataUtils); + const reportDataBuilder = reportDataBuilderFactory(transactionTypes)(pointOfSaleDataUtils); return reportDataBuilder.buildReportData(transactionType, transactionData, productData); } From 24dc14f93cf892d93b81b08a0c5fc7d254ebfadf Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 12:46:13 -0800 Subject: [PATCH 11/63] docs: added file paths to comments --- test/4_test-dummy-form.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/4_test-dummy-form.test.js b/test/4_test-dummy-form.test.js index c7e75db..e15652c 100644 --- a/test/4_test-dummy-form.test.js +++ b/test/4_test-dummy-form.test.js @@ -65,6 +65,9 @@ describe('Test Dummy Form - Costume Shop Sales', function () { }); describe('sales report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js describe('get sales report', function () { it('returns a sales report with no sales'); From 604c4d88c3d6743b3d0d16d1397ac7de0e65bb35 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 12:53:14 -0800 Subject: [PATCH 12/63] docs: added important files form4 --- .../pointOfSaleDataUtils/importantFiles.md | 2 +- .../form4-doc/salesReport/_main.md | 4 +++- .../form4-doc/salesReport/importantFiles.md | 18 +++++++++++++++ docs/TEST-DUMMY-FORM.md | 23 +++++++++++++++++-- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/salesReport/importantFiles.md diff --git a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md index 384b3da..c88827c 100644 --- a/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md +++ b/docs-source/forms-source/form4-doc/pointOfSaleDataUtils/importantFiles.md @@ -1,6 +1,6 @@ diff --git a/docs-source/forms-source/form4-doc/salesReport/_main.md b/docs-source/forms-source/form4-doc/salesReport/_main.md index 3464dfa..1c30b57 100644 --- a/docs-source/forms-source/form4-doc/salesReport/_main.md +++ b/docs-source/forms-source/form4-doc/salesReport/_main.md @@ -3,6 +3,8 @@ (title "Sales Report") ) /bl--> +This will be a bit more in depth about the skills needed to write tests. + -Sales report documentation coming... \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/salesReport/importantFiles.md b/docs-source/forms-source/form4-doc/salesReport/importantFiles.md new file mode 100644 index 0000000..3b59e21 --- /dev/null +++ b/docs-source/forms-source/form4-doc/salesReport/importantFiles.md @@ -0,0 +1,18 @@ + + +Test File: + +> test/[4_test-dummy-form.test.js](../test/4_test-dummy-form.test.js) + +Files Under Test: + +> jsforms-source/4_test-dummy-form/sales-reporter/[salesReporterFactory.js](../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js) +> jsforms-source/4_test-dummy-form/pos-transaction-services/[reportDataBuilder.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js) + +Helpers File: + +> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index e21d616..8431786 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -166,7 +166,7 @@ TBD ## Point of Sale Data Utilities ## -### Important Files ### +### Point of Sale Data Utilities — Important Files ### Test File: @@ -1162,7 +1162,26 @@ In the "Arrange" you will be creating 3 different transaction reports. Two will ## Sales Report ## -Sales report documentation coming... +This will be a bit more in depth about the skills needed to write tests. + + +### Sales Report — Important Files ### + +Test File: + +> test/[4_test-dummy-form.test.js](../test/4_test-dummy-form.test.js) + +Files Under Test: + +> jsforms-source/4_test-dummy-form/sales-reporter/[salesReporterFactory.js](../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js) +> jsforms-source/4_test-dummy-form/pos-transaction-services/[reportDataBuilder.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js) + +Helpers File: + +> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) + + + ## TDB ## From 00f21da840a31e5a6552b87d8eba732e7fc69423 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 13:38:24 -0800 Subject: [PATCH 13/63] docs: refactoring form4 --- docs-source/forms-source/form4-doc/_main.md | 2 +- docs-source/forms-source/form4-doc/app/_main.md | 12 ++++++++++++ .../pointOfSaleDataUtilityFactoryBuilder.md} | 16 ++++------------ .../form4-doc/app/reportDataBuilderFactory.md | 7 +++++++ docs/TEST-DUMMY-FORM.md | 9 ++++++--- 5 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/app/_main.md rename docs-source/forms-source/form4-doc/{app.md => app/pointOfSaleDataUtilityFactoryBuilder.md} (90%) create mode 100644 docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index e272931..4591d2c 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -16,7 +16,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (table-of-contents (section-main "./why.md") (section-main "./hints.md") - (section-main "./app.md") + (section-main "./app/_main.md") (section-main "./pointOfSaleDataUtils/_main.md") (section-main "./salesReport/_main.md") ) diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md new file mode 100644 index 0000000..19d7130 --- /dev/null +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -0,0 +1,12 @@ + + +The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. + + \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app.md b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md similarity index 90% rename from docs-source/forms-source/form4-doc/app.md rename to docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md index f0d7160..d198f67 100644 --- a/docs-source/forms-source/form4-doc/app.md +++ b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md @@ -1,13 +1,9 @@ -The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. - -### Point Of Sale Data Utility Factory Builder - File: [/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) This will build the utility that calculates counts for items based on their transaction status. @@ -16,7 +12,7 @@ This function takes a single parameter `transactionStatuses` that allow the stat `Sale` which is a constant number that maps to transactions caused by the sale of product. For our tests we will configure this to have the value `1`. -and +and `Return` which is a constant number that maps to transactions caused by the return of product. For our tests we will configure this to have the value `2`. @@ -73,7 +69,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -### `getProductCountByReturn` +#### `getProductCountByReturn` This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -120,8 +116,4 @@ The result should look like the following: } ``` -Because there is a total of 3 items returned of Product ID 3, and 5 items returned of Product ID 6. - -### Report Data Builder Factory - -TBD \ No newline at end of file +Because there is a total of 3 items returned of Product ID 3, and 5 items returned of Product ID 6. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md new file mode 100644 index 0000000..283f24d --- /dev/null +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -0,0 +1,7 @@ + + +TBD \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 8431786..dca9611 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -43,7 +43,8 @@ This section is doable without the hints. it is _hard_ but doable. However, the The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. -### Point Of Sale Data Utility Factory Builder + +### Point Of Sale Data Utility Factory Builder ### File: [/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) @@ -110,7 +111,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -### `getProductCountByReturn` +#### `getProductCountByReturn` This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -158,11 +159,13 @@ The result should look like the following: ``` Because there is a total of 3 items returned of Product ID 3, and 5 items returned of Product ID 6. + -### Report Data Builder Factory +### Report Data Builder Factory ### TBD + ## Point of Sale Data Utilities ## From 6b3ef818b32e6fa7d3be5041346341f1d3c4156d Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 13:41:01 -0800 Subject: [PATCH 14/63] docs: refactoring form4 --- docs-source/forms-source/form4-doc/_main.md | 2 +- .../forms-source/form4-doc/{why.md => why/_main.md} | 0 docs-source/forms-source/form4-doc/{ => why}/why1.md | 0 docs-source/forms-source/form4-doc/{ => why}/why2.md | 0 docs-source/forms-source/why.md | 12 ++++++++++++ 5 files changed, 13 insertions(+), 1 deletion(-) rename docs-source/forms-source/form4-doc/{why.md => why/_main.md} (100%) rename docs-source/forms-source/form4-doc/{ => why}/why1.md (100%) rename docs-source/forms-source/form4-doc/{ => why}/why2.md (100%) create mode 100644 docs-source/forms-source/why.md diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 4591d2c..0d25bdc 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -14,7 +14,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy + +There are two main reasons: + + \ No newline at end of file From a27136beac93d3ed24055e45a12ce767b85dddd1 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 13:46:30 -0800 Subject: [PATCH 15/63] docs: added stubs for appliction docs --- docs-source/forms-source/form4-doc/app/_main.md | 3 ++- .../forms-source/form4-doc/app/reportDataBuilderFactory.md | 2 +- .../forms-source/form4-doc/app/salesReporterFactory.md | 6 ++++++ docs/TEST-DUMMY-FORM.md | 7 ++++++- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 docs-source/forms-source/form4-doc/app/salesReporterFactory.md diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md index 19d7130..c8ef231 100644 --- a/docs-source/forms-source/form4-doc/app/_main.md +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -9,4 +9,5 @@ The application under test is a Point of Sale reporting utility. It will report \ No newline at end of file + (section "./salesReporterFactory.md") +/bl--> diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md index 283f24d..633f6ef 100644 --- a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -4,4 +4,4 @@ ) /bl--> -TBD \ No newline at end of file +Documentation for the Report Data Builder Factory coming. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md new file mode 100644 index 0000000..6fd57ae --- /dev/null +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -0,0 +1,6 @@ + +Documentation on Sales Reporter Factory coming. \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index dca9611..5c83038 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -163,8 +163,13 @@ Because there is a total of 3 items returned of Product ID 3, and 5 items return ### Report Data Builder Factory ### -TBD +Documentation for the Report Data Builder Factory coming. + +### Sales Reporter Factory ### +Documentation on Sales Reporter Factory coming. + + ## Point of Sale Data Utilities ## From 86bf585a73adee14d173dfccd2cfb397c12bd2e0 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 13:48:06 -0800 Subject: [PATCH 16/63] docs: fixed spacing --- docs-source/forms-source/form4-doc/app/salesReporterFactory.md | 1 + docs/TEST-DUMMY-FORM.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md index 6fd57ae..4d63953 100644 --- a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -3,4 +3,5 @@ (title "Sales Reporter Factory") ) /bl--> + Documentation on Sales Reporter Factory coming. \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 5c83038..49b7994 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -167,6 +167,7 @@ Documentation for the Report Data Builder Factory coming. ### Sales Reporter Factory ### + Documentation on Sales Reporter Factory coming. From 9f7c148907d5cf3c5859fbd75f9c5b76f7498b0b Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 13:51:32 -0800 Subject: [PATCH 17/63] docs: fixed minor things --- FORMS.md | 1 - docs-source/forms-source/form4-doc/app/_main.md | 2 +- docs-source/forms-source/form4-doc/salesReport/_main.md | 2 +- .../forms-source/form4-doc/salesReport/importantFiles.md | 2 +- docs-source/forms-source/form4-doc/why/why2.md | 2 +- docs-source/forms-source/forms.md | 2 +- docs/TEST-DUMMY-FORM.md | 5 +---- 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/FORMS.md b/FORMS.md index 8900c60..e5bf91f 100644 --- a/FORMS.md +++ b/FORMS.md @@ -14,7 +14,6 @@ 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) 3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) - diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md index c8ef231..0b7fc07 100644 --- a/docs-source/forms-source/form4-doc/app/_main.md +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -10,4 +10,4 @@ The application under test is a Point of Sale reporting utility. It will report (section "./pointOfSaleDataUtilityFactoryBuilder.md") (section "./reportDataBuilderFactory.md") (section "./salesReporterFactory.md") -/bl--> +/bl--> \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/salesReport/_main.md b/docs-source/forms-source/form4-doc/salesReport/_main.md index 1c30b57..9ef3c35 100644 --- a/docs-source/forms-source/form4-doc/salesReport/_main.md +++ b/docs-source/forms-source/form4-doc/salesReport/_main.md @@ -7,4 +7,4 @@ This will be a bit more in depth about the skills needed to write tests. +/bl--> \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/salesReport/importantFiles.md b/docs-source/forms-source/form4-doc/salesReport/importantFiles.md index 3b59e21..a918a49 100644 --- a/docs-source/forms-source/form4-doc/salesReport/importantFiles.md +++ b/docs-source/forms-source/form4-doc/salesReport/importantFiles.md @@ -15,4 +15,4 @@ Files Under Test: Helpers File: -> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) +> test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/why/why2.md b/docs-source/forms-source/form4-doc/why/why2.md index ebe2390..23dddfc 100644 --- a/docs-source/forms-source/form4-doc/why/why2.md +++ b/docs-source/forms-source/form4-doc/why/why2.md @@ -4,4 +4,4 @@ ) /bl--> -The biggest reason to test a known working code base is to ensure that it stays working. You will see by testing this code base that coming into a code base you do not understand and gaining that understanding is hard work. Having tests around that code ensures that someone unfamiliar with, or has been away to long from, the code base does not accidently break existing functionality. \ No newline at end of file +The biggest reason to test a known working code base is to ensure that it stays working. You will see by testing this code base that coming into a code base you do not understand and gaining that understanding is hard work. Having tests around that code ensures that someone unfamiliar with, or has been away to long from, the code base does not accidentally break existing functionality. \ No newline at end of file diff --git a/docs-source/forms-source/forms.md b/docs-source/forms-source/forms.md index da22a5d..bfe5bb5 100644 --- a/docs-source/forms-source/forms.md +++ b/docs-source/forms-source/forms.md @@ -7,4 +7,4 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) +3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 49b7994..6bb7515 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -30,7 +30,7 @@ By writing tests for this code, you will gain understanding of _how_ to write te ### Regression ### -The biggest reason to test a known working code base is to ensure that it stays working. You will see by testing this code base that coming into a code base you do not understand and gaining that understanding is hard work. Having tests around that code ensures that someone unfamiliar with, or has been away to long from, the code base does not accidently break existing functionality. +The biggest reason to test a known working code base is to ensure that it stays working. You will see by testing this code base that coming into a code base you do not understand and gaining that understanding is hard work. Having tests around that code ensures that someone unfamiliar with, or has been away to long from, the code base does not accidentally break existing functionality. @@ -170,7 +170,6 @@ Documentation for the Report Data Builder Factory coming. Documentation on Sales Reporter Factory coming. - ## Point of Sale Data Utilities ## @@ -1188,9 +1187,7 @@ Files Under Test: Helpers File: > test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) - - ## TDB ## From a3a666eecdeae809d2ff6812e6ec2322d90fe7b8 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 14:19:02 -0800 Subject: [PATCH 18/63] docs: working on documenting app --- .../form4-doc/app/reportDataBuilderFactory.md | 57 ++++++++++++++++++- docs/TEST-DUMMY-FORM.md | 57 ++++++++++++++++++- .../reportDataBuilder.js | 6 +- 3 files changed, 115 insertions(+), 5 deletions(-) diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md index 633f6ef..373e568 100644 --- a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -4,4 +4,59 @@ ) /bl--> -Documentation for the Report Data Builder Factory coming. \ No newline at end of file +This is a function with the following signature: + +```javascript + function reportDataBuilderFactory(transactionStatuses) +``` + +It takes an object with the following shape: + +```javascript + { + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number + } +``` + +It then returns an object with the following structure: + +```javascript +{ + buildReportData +} +``` + +The `buildReportData` is a function that has the following signature: + +```javascript + buildReportData(transactionStatus /*integer number*/, transactionData /*object array*/, productData /*object array*/) +``` + +The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. + +The `transactionData` parameter is an array of objects with the following structure: + +```javascript +{ + productId, // integer number -- id from a product record + transactionStatus, // integer number -- sale or return, must match the transactionStatuses object + quantity // integer number -- count sold or returned +} +``` + +The `productData` parameter is an array of objects that have the following structure: + +```javascript +{ + id, // integer number -- id uniquely identifies this product + name, // string -- Name of product + price // number -- the sales price for a single item of this product +} +``` + +The `buildReportData` function returns an array of objects that have the following structure: + +```javascript + // ? +``` \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 6bb7515..fc8ea1f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -163,7 +163,62 @@ Because there is a total of 3 items returned of Product ID 3, and 5 items return ### Report Data Builder Factory ### -Documentation for the Report Data Builder Factory coming. +This is a function with the following signature: + +```javascript + function reportDataBuilderFactory(transactionStatuses) +``` + +It takes an object with the following shape: + +```javascript + { + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number + } +``` + +It then returns an object with the following structure: + +```javascript +{ + buildReportData +} +``` + +The `buildReportData` is a function that has the following signature: + +```javascript + buildReportData(transactionStatus /*integer number*/, transactionData /*object array*/, productData /*object array*/) +``` + +The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. + +The `transactionData` parameter is an array of objects with the following structure: + +```javascript +{ + productId, // integer number -- id from a product record + transactionStatus, // integer number -- sale or return, must match the transactionStatuses object + quantity // integer number -- count sold or returned +} +``` + +The `productData` parameter is an array of objects that have the following structure: + +```javascript +{ + id, // integer number -- id uniquely identifies this product + name, // string -- Name of product + price // number -- the sales price for a single item of this product +} +``` + +The `buildReportData` function returns an array of objects that have the following structure: + +```javascript + // ? +``` ### Sales Reporter Factory ### diff --git a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js index b225b9f..c319906 100644 --- a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js +++ b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js @@ -40,13 +40,13 @@ function reportDataBuilderFactory(transactionStatuses) { : pointOfSaleDataUtils.getProductCountByReturn; } - function buildReportData(transactionType, transactionData, productData) { - const getProductCounts = pickProductCountAction(transactionType); + function buildReportData(transactionStatus, transactionData, productData) { + const getProductCounts = pickProductCountAction(transactionStatus); const productCounts = getProductCounts(transactionData); return getObjectElements(productData) .filter(isProductInCountData(productCounts)) - .map(buildProductTransactionRecord(productCounts, transactionType)) + .map(buildProductTransactionRecord(productCounts, transactionStatus)) } return { From 5a1a243f93e5319c780b0a74797154c024e0c71f Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 14:36:06 -0800 Subject: [PATCH 19/63] feat: added more test data --- test/form-helpers/4_test-dummy-helpers.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/form-helpers/4_test-dummy-helpers.js b/test/form-helpers/4_test-dummy-helpers.js index c9d9a40..a7b3ad5 100644 --- a/test/form-helpers/4_test-dummy-helpers.js +++ b/test/form-helpers/4_test-dummy-helpers.js @@ -19,6 +19,16 @@ const fourthFormHelpers = (function () { id: 2, name: 'Robot Costume', price: 59.99 + }, + { + id: 3, + name: 'Cow Costume', + price: 49.99 + }, + { + id: 3, + name: 'Doctor Costume', + price: 35.99 } ]; } From 3d40bf86ee5579a70384729a1f93f62864538df4 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 15:01:13 -0800 Subject: [PATCH 20/63] docs: working on app docs --- .../forms-source/form4-doc/app/_main.md | 2 +- .../form4-doc/app/reportDataBuilderFactory.md | 24 ++++- .../form4-doc/app/salesReporterFactory.md | 62 +++++++++++- docs/TEST-DUMMY-FORM.md | 94 +++++++++++++++++-- 4 files changed, 167 insertions(+), 15 deletions(-) diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md index 0b7fc07..06afc43 100644 --- a/docs-source/forms-source/form4-doc/app/_main.md +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -8,6 +8,6 @@ The application under test is a Point of Sale reporting utility. It will report \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md index 373e568..e03ca74 100644 --- a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -4,12 +4,14 @@ ) /bl--> -This is a function with the following signature: +The function `reportDataBuilderFactory` has the following signature: ```javascript function reportDataBuilderFactory(transactionStatuses) ``` +#### Report Data Builder Factory Parameter #### + It takes an object with the following shape: ```javascript @@ -19,6 +21,8 @@ It takes an object with the following shape: } ``` +#### Report Data Builder Factory Return Value #### + It then returns an object with the following structure: ```javascript @@ -27,10 +31,16 @@ It then returns an object with the following structure: } ``` +##### Build Report Data Parameters ##### + The `buildReportData` is a function that has the following signature: ```javascript - buildReportData(transactionStatus /*integer number*/, transactionData /*object array*/, productData /*object array*/) + buildReportData( + transactionStatus /*integer number*/, + transactionData /*object array*/, + productData /*object array*/ + ) ``` The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. @@ -39,7 +49,7 @@ The `transactionData` parameter is an array of objects with the following struct ```javascript { - productId, // integer number -- id from a product record + productId, // integer number -- id from a product datum transactionStatus, // integer number -- sale or return, must match the transactionStatuses object quantity // integer number -- count sold or returned } @@ -55,8 +65,14 @@ The `productData` parameter is an array of objects that have the following struc } ``` +##### Build Report Data Return Value ##### + The `buildReportData` function returns an array of objects that have the following structure: ```javascript - // ? +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} ``` \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md index 4d63953..48786af 100644 --- a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -4,4 +4,64 @@ ) /bl--> -Documentation on Sales Reporter Factory coming. \ No newline at end of file +The `salesReporterFactory` function has the following signature + +```javascript +function salesReporterFactory( + dataLoader, + pointOfSaleDataUtilsFactory, + reportDataBuilderFactory +) +``` + +#### Sales Reporter Factory Parameters #### + +The `dataLoader` parameter is an object with following shape: + +```javascript +{ + getProductData, + getTransactionData, + getTransactionTypes +} +``` + +##### Get Product Data Function ##### + +The getProductData function has the following signature: + +```javascript +getProductData() +``` + +###### Get Product Data Return Value ###### + +The `getProductData` function returns an array of objects that have then following structure: + +```javascript +{ + id, // integer number -- id uniquely identifies this product + name, // string -- Name of product + price // number -- the sales price for a single item of this product +} +``` + +##### Get Transaction Data Function ##### + +The `getTransactionData` function has the following signature: + +```javascript +getTransactionData() +``` + +###### Get Transaction Data Return Value ###### + +The `getTransactionData` function returns an array of objects that have the following structure: + +```javascript +{ + productId, // integer number -- id from a product datum + transactionStatus, // integer number -- sale or return, must match the transactionStatuses object + quantity // integer number -- count sold or returned +} +``` \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index fc8ea1f..cbd9ba3 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -161,14 +161,81 @@ The result should look like the following: Because there is a total of 3 items returned of Product ID 3, and 5 items returned of Product ID 6. +### Sales Reporter Factory ### + +The `salesReporterFactory` function has the following signature + +```javascript +function salesReporterFactory( + dataLoader, + pointOfSaleDataUtilsFactory, + reportDataBuilderFactory +) +``` + +#### Sales Reporter Factory Parameters #### + +The `dataLoader` parameter is an object with following shape: + +```javascript +{ + getProductData, + getTransactionData, + getTransactionTypes +} +``` + +##### Get Product Data Function ##### + +The getProductData function has the following signature: + +```javascript +getProductData() +``` + +###### Get Product Data Return Value ###### + +The `getProductData` function returns an array of objects that have then following structure: + +```javascript +{ + id, // integer number -- id uniquely identifies this product + name, // string -- Name of product + price // number -- the sales price for a single item of this product +} +``` + +##### Get Transaction Data Function ##### + +The `getTransactionData` function has the following signature: + +```javascript +getTransactionData() +``` + +###### Get Transaction Data Return Value ###### + +The `getTransactionData` function returns an array of objects that have the following structure: + +```javascript +{ + productId, // integer number -- id from a product datum + transactionStatus, // integer number -- sale or return, must match the transactionStatuses object + quantity // integer number -- count sold or returned +} +``` + + ### Report Data Builder Factory ### -This is a function with the following signature: +The function `reportDataBuilderFactory` has the following signature: ```javascript function reportDataBuilderFactory(transactionStatuses) ``` +#### Report Data Builder Factory Parameter #### + It takes an object with the following shape: ```javascript @@ -178,6 +245,8 @@ It takes an object with the following shape: } ``` +#### Report Data Builder Factory Return Value #### + It then returns an object with the following structure: ```javascript @@ -186,10 +255,16 @@ It then returns an object with the following structure: } ``` +##### Build Report Data Parameters ##### + The `buildReportData` is a function that has the following signature: ```javascript - buildReportData(transactionStatus /*integer number*/, transactionData /*object array*/, productData /*object array*/) + buildReportData( + transactionStatus /*integer number*/, + transactionData /*object array*/, + productData /*object array*/ + ) ``` The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. @@ -198,7 +273,7 @@ The `transactionData` parameter is an array of objects with the following struct ```javascript { - productId, // integer number -- id from a product record + productId, // integer number -- id from a product datum transactionStatus, // integer number -- sale or return, must match the transactionStatuses object quantity // integer number -- count sold or returned } @@ -214,17 +289,18 @@ The `productData` parameter is an array of objects that have the following struc } ``` +##### Build Report Data Return Value ##### + The `buildReportData` function returns an array of objects that have the following structure: ```javascript - // ? +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} ``` - -### Sales Reporter Factory ### - -Documentation on Sales Reporter Factory coming. - ## Point of Sale Data Utilities ## From 790d018f679a42ebad234de254849b8dbc961cd9 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Tue, 21 Feb 2023 15:42:31 -0800 Subject: [PATCH 21/63] docs: more app documentation --- .../form4-doc/app/reportDataBuilderFactory.md | 20 +++++----- .../form4-doc/app/salesReporterFactory.md | 19 +++++++++ docs/TEST-DUMMY-FORM.md | 39 ++++++++++++++----- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md index e03ca74..3b06b0a 100644 --- a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -7,7 +7,7 @@ The function `reportDataBuilderFactory` has the following signature: ```javascript - function reportDataBuilderFactory(transactionStatuses) +function reportDataBuilderFactory(transactionStatuses) ``` #### Report Data Builder Factory Parameter #### @@ -15,10 +15,10 @@ The function `reportDataBuilderFactory` has the following signature: It takes an object with the following shape: ```javascript - { - Sale = X, // where X is an integer number - Return = Y // where Y is an integer number - } +{ + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number +} ``` #### Report Data Builder Factory Return Value #### @@ -36,11 +36,11 @@ It then returns an object with the following structure: The `buildReportData` is a function that has the following signature: ```javascript - buildReportData( - transactionStatus /*integer number*/, - transactionData /*object array*/, - productData /*object array*/ - ) +buildReportData( + transactionStatus /*integer number*/, + transactionData /*object array*/, + productData /*object array*/ +) ``` The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md index 48786af..a7db5d6 100644 --- a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -64,4 +64,23 @@ The `getTransactionData` function returns an array of objects that have the foll transactionStatus, // integer number -- sale or return, must match the transactionStatuses object quantity // integer number -- count sold or returned } +``` + +##### Get Transaction Types Function ##### + +The `getTransactionTypes` function has the following signature: + +```javascript +getTransactionTypes() +``` + +###### Get Transaction Types Return Value ###### + +The `getTransactionTypes` function returns an object with the following structure: + +```javascript +{ + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number +} ``` \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index cbd9ba3..dacbf1d 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -224,6 +224,25 @@ The `getTransactionData` function returns an array of objects that have the foll quantity // integer number -- count sold or returned } ``` + +##### Get Transaction Types Function ##### + +The `getTransactionTypes` function has the following signature: + +```javascript +getTransactionTypes() +``` + +###### Get Transaction Types Return Value ###### + +The `getTransactionTypes` function returns an object with the following structure: + +```javascript +{ + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number +} +``` ### Report Data Builder Factory ### @@ -231,7 +250,7 @@ The `getTransactionData` function returns an array of objects that have the foll The function `reportDataBuilderFactory` has the following signature: ```javascript - function reportDataBuilderFactory(transactionStatuses) +function reportDataBuilderFactory(transactionStatuses) ``` #### Report Data Builder Factory Parameter #### @@ -239,10 +258,10 @@ The function `reportDataBuilderFactory` has the following signature: It takes an object with the following shape: ```javascript - { - Sale = X, // where X is an integer number - Return = Y // where Y is an integer number - } +{ + Sale = X, // where X is an integer number + Return = Y // where Y is an integer number +} ``` #### Report Data Builder Factory Return Value #### @@ -260,11 +279,11 @@ It then returns an object with the following structure: The `buildReportData` is a function that has the following signature: ```javascript - buildReportData( - transactionStatus /*integer number*/, - transactionData /*object array*/, - productData /*object array*/ - ) +buildReportData( + transactionStatus /*integer number*/, + transactionData /*object array*/, + productData /*object array*/ +) ``` The `transactionStatus` parameter maps to one of the integers in the `transactionStatuses` object. From c5e1f9978904a1efabe2c70976846d62882ec5e1 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 07:32:41 -0800 Subject: [PATCH 22/63] docs: reorganized tests form4 --- docs-source/forms-source/form4-doc/_main.md | 2 +- .../form4-doc/{salesReport => getReport}/_main.md | 2 +- .../{salesReport => getReport}/importantFiles.md | 0 docs/TEST-DUMMY-FORM.md | 4 ++-- test/4_test-dummy-form.test.js | 9 ++++----- 5 files changed, 8 insertions(+), 9 deletions(-) rename docs-source/forms-source/form4-doc/{salesReport => getReport}/_main.md (83%) rename docs-source/forms-source/form4-doc/{salesReport => getReport}/importantFiles.md (100%) diff --git a/docs-source/forms-source/form4-doc/_main.md b/docs-source/forms-source/form4-doc/_main.md index 0d25bdc..04a36ae 100644 --- a/docs-source/forms-source/form4-doc/_main.md +++ b/docs-source/forms-source/form4-doc/_main.md @@ -18,7 +18,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy (section-main "./hints.md") (section-main "./app/_main.md") (section-main "./pointOfSaleDataUtils/_main.md") - (section-main "./salesReport/_main.md") + (section-main "./getReport/_main.md") ) /bl--> ## TDB ## \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/salesReport/_main.md b/docs-source/forms-source/form4-doc/getReport/_main.md similarity index 83% rename from docs-source/forms-source/form4-doc/salesReport/_main.md rename to docs-source/forms-source/form4-doc/getReport/_main.md index 9ef3c35..3ba6e1c 100644 --- a/docs-source/forms-source/form4-doc/salesReport/_main.md +++ b/docs-source/forms-source/form4-doc/getReport/_main.md @@ -1,6 +1,6 @@ This will be a bit more in depth about the skills needed to write tests. diff --git a/docs-source/forms-source/form4-doc/salesReport/importantFiles.md b/docs-source/forms-source/form4-doc/getReport/importantFiles.md similarity index 100% rename from docs-source/forms-source/form4-doc/salesReport/importantFiles.md rename to docs-source/forms-source/form4-doc/getReport/importantFiles.md diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index dacbf1d..401177f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -16,7 +16,7 @@ You will be working in the [test/4_test-dummy-form.test.js](../test/4_test-dummy - [Section 2: A word about hints](#user-content-a-word-about-hints) - [Section 3: The application under test](#user-content-the-application-under-test) - [Section 4: Point of Sale Data Utilities](#user-content-point-of-sale-data-utilities) -- [Section 5: Sales Report](#user-content-sales-report) +- [Section 5: Get Report](#user-content-get-report) ## Why would I write tests for code I know works? ## @@ -1319,7 +1319,7 @@ In the "Arrange" you will be creating 3 different transaction reports. Two will -## Sales Report ## +## Get Report ## This will be a bit more in depth about the skills needed to write tests. diff --git a/test/4_test-dummy-form.test.js b/test/4_test-dummy-form.test.js index e15652c..52ab0ff 100644 --- a/test/4_test-dummy-form.test.js +++ b/test/4_test-dummy-form.test.js @@ -64,7 +64,7 @@ describe('Test Dummy Form - Costume Shop Sales', function () { }); }); - describe('sales report', function () { + describe('get report', function () { // files being tested are: // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js @@ -79,10 +79,9 @@ describe('Test Dummy Form - Costume Shop Sales', function () { it('returns a sales report with no "returns" data'); }); - }); - describe('returns report', function () { - it('returns a "returns" report with no "sales" data'); + describe('get returns report', function () { + it('returns a "returns" report with no "sales" data'); + }); }); - }); From a8fb957ae49a66cf14e891d0baab7b7a5b30ce7c Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 07:52:35 -0800 Subject: [PATCH 23/63] docs: updated description form4 --- docs-source/forms-source/form4-doc/getReport/_main.md | 2 +- docs/TEST-DUMMY-FORM.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/_main.md b/docs-source/forms-source/form4-doc/getReport/_main.md index 3ba6e1c..77987d5 100644 --- a/docs-source/forms-source/form4-doc/getReport/_main.md +++ b/docs-source/forms-source/form4-doc/getReport/_main.md @@ -3,8 +3,8 @@ (title "Get Report") ) /bl--> -This will be a bit more in depth about the skills needed to write tests. +In testing the `getReport` method, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 401177f..56dd7ba 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1320,8 +1320,8 @@ In the "Arrange" you will be creating 3 different transaction reports. Two will ## Get Report ## -This will be a bit more in depth about the skills needed to write tests. +In testing the `getReport` method, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. ### Sales Report — Important Files ### From d2f6af75cc65c781554904080e790d47974dde3b Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:06:09 -0800 Subject: [PATCH 24/63] docs: working on form4 --- .../form4-doc/app/salesReporterFactory.md | 28 +++++++++++++ .../forms-source/form4-doc/getReport/_main.md | 5 ++- .../form4-doc/getReport/getSalesReport.md | 41 +++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 docs-source/forms-source/form4-doc/getReport/getSalesReport.md diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md index a7db5d6..2922762 100644 --- a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -83,4 +83,32 @@ The `getTransactionTypes` function returns an object with the following structur Sale = X, // where X is an integer number Return = Y // where Y is an integer number } +``` + +#### Sales Reporter Factory Return Value #### + +The `` function returns an object with the following structure: + +```javascript +{ + getReport +} +``` + +##### Get Report Function ##### + +The `getReport` function has the following signature: + +```javascript +function getReport(transactionType) +``` + +The `transactionType` parameter is an integer number that maps to Sale or Return as determined by the `transactionTypes` returned from the `getTransactionTypes` function. + +###### Get Report Return Value ###### + +The `getReport` function returns an object with the following structure: + +```javascript +// ? ``` \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getReport/_main.md b/docs-source/forms-source/form4-doc/getReport/_main.md index 77987d5..fb4a80a 100644 --- a/docs-source/forms-source/form4-doc/getReport/_main.md +++ b/docs-source/forms-source/form4-doc/getReport/_main.md @@ -4,7 +4,10 @@ ) /bl--> -In testing the `getReport` method, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. +In testing the `getReport` function, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. + +The `getReport` function can either create a Sales report or a Returns report. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md new file mode 100644 index 0000000..971fbf3 --- /dev/null +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -0,0 +1,41 @@ + + +You will be focusing on testing that a sales report is created correctly. In creating these tests you will follow the basic steps listed bellow. + +1. Write the first test. +2. Write the second test. +3. Refactor tests to remove repetitive code into a `beforeEach` block. +4. Finish writing tests, stopping periodically to refactor as needed. + +Now when you write each test, you will follow the process you did before with one additional step. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +#### It returns a sales report with no sales #### + +Starting with a base case of there were no sales, you will write the test that proves that it returns a report with nothing in it. + +To test the `getReport` function you will need to first call the `salesReporterFactory` function. The `salesReporterFactory` has the following signature: + +```javascript +function salesReporterFactory( + dataLoader, + pointOfSaleDataUtilsFactory, + reportDataBuilderFactory +) +``` + +You will have to create a fake `dataLoader`, use the `pointOfSaleDataUtilsFactoryBuilder` to get the `pointOfSaleDataUtilsFactory` and simply pass the `reportDataBuilderFactory` that is already available to the test. \ No newline at end of file From a87667ee35815e645418cdb492dc6670ed03184e Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:20:58 -0800 Subject: [PATCH 25/63] refactor: making names match --- docs/TEST-DUMMY-FORM.md | 71 ++++++++++++++++++- .../data-access/dataLoaderFactory.js | 6 +- .../data-access/dataSourceAccessFactory.js | 2 +- .../reportDataBuilder.js | 16 ++--- .../sales-reporter/salesReporterFactory.js | 10 +-- test/form-helpers/4_test-dummy-helpers.js | 2 +- 6 files changed, 88 insertions(+), 19 deletions(-) diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 56dd7ba..9ad0393 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -243,6 +243,34 @@ The `getTransactionTypes` function returns an object with the following structur Return = Y // where Y is an integer number } ``` + +#### Sales Reporter Factory Return Value #### + +The `` function returns an object with the following structure: + +```javascript +{ + getReport +} +``` + +##### Get Report Function ##### + +The `getReport` function has the following signature: + +```javascript +function getReport(transactionType) +``` + +The `transactionType` parameter is an integer number that maps to Sale or Return as determined by the `transactionTypes` returned from the `getTransactionTypes` function. + +###### Get Report Return Value ###### + +The `getReport` function returns an object with the following structure: + +```javascript +// ? +``` ### Report Data Builder Factory ### @@ -1321,7 +1349,9 @@ In the "Arrange" you will be creating 3 different transaction reports. Two will ## Get Report ## -In testing the `getReport` method, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. +In testing the `getReport` function, you will be required to do a lot more of the initial work. Fortunately you have the code from the "get product count by sale" test suite you just finished. + +The `getReport` function can either create a Sales report or a Returns report. ### Sales Report — Important Files ### @@ -1338,6 +1368,45 @@ Helpers File: > test/form-helpers/[4_test-dummy-helpers.js](../test/form-helpers/4_test-dummy-helpers.js) + +### Get Sales Report ### + +You will be focusing on testing that a sales report is created correctly. In creating these tests you will follow the basic steps listed bellow. + +1. Write the first test. +2. Write the second test. +3. Refactor tests to remove repetitive code into a `beforeEach` block. +4. Finish writing tests, stopping periodically to refactor as needed. + +Now when you write each test, you will follow the process you did before with one additional step. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +#### It returns a sales report with no sales #### + +Starting with a base case of there were no sales, you will write the test that proves that it returns a report with nothing in it. + +To test the `getReport` function you will need to first call the `salesReporterFactory` function. The `salesReporterFactory` has the following signature: + +```javascript +function salesReporterFactory( + dataLoader, + pointOfSaleDataUtilsFactory, + reportDataBuilderFactory +) +``` + +You will have to create a fake `dataLoader`, use the `pointOfSaleDataUtilsFactoryBuilder` to get the `pointOfSaleDataUtilsFactory` and simply pass the `reportDataBuilderFactory` that is already available to the test. + ## TDB ## diff --git a/jsforms-source/4_test-dummy-form/data-access/dataLoaderFactory.js b/jsforms-source/4_test-dummy-form/data-access/dataLoaderFactory.js index d3bfcb7..a270a1b 100644 --- a/jsforms-source/4_test-dummy-form/data-access/dataLoaderFactory.js +++ b/jsforms-source/4_test-dummy-form/data-access/dataLoaderFactory.js @@ -8,13 +8,13 @@ function dataLoaderFactory(dataSourceAccess) { return dataSourceAccess.loadTransactionData() } - function getTransactionTypes() { - return dataSourceAccess.loadTransactionTypes(); + function getTransactionStatuses() { + return dataSourceAccess.loadTransactionStatuses(); } return { getProductData: getProductData, getTransactionData: getTransactionData, - getTransactionTypes: getTransactionTypes + getTransactionStatuses: getTransactionStatuses }; } diff --git a/jsforms-source/4_test-dummy-form/data-access/dataSourceAccessFactory.js b/jsforms-source/4_test-dummy-form/data-access/dataSourceAccessFactory.js index f30f3b4..0efe440 100644 --- a/jsforms-source/4_test-dummy-form/data-access/dataSourceAccessFactory.js +++ b/jsforms-source/4_test-dummy-form/data-access/dataSourceAccessFactory.js @@ -6,7 +6,7 @@ function dataSourceAccessFactory() { return { loadTransactionData: throwOnLoad, - loadTransactionTypes: throwOnLoad, + loadTransactionStatuses: throwOnLoad, loadProductTypes: throwOnLoad }; } diff --git a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js index c319906..89f37ec 100644 --- a/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js +++ b/jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js @@ -6,18 +6,18 @@ function reportDataBuilderFactory(transactionStatuses) { .map(key => dataObject[key]); } - function isSaleType(transactionType) { - return transactionType === transactionStatuses.Sale; + function isSaleType(transactionStatus) { + return transactionStatus === transactionStatuses.Sale; } - function getTotalSignMultiplier(transactionType) { - return isSaleType(transactionType) ? 1 : -1; + function getTotalSignMultiplier(transactionStatus) { + return isSaleType(transactionStatus) ? 1 : -1; } - function buildProductTransactionRecord(productCounts, transactionType) { + function buildProductTransactionRecord(productCounts, transactionStatus) { return function (product) { const quantity = productCounts[product.id]; - const signMultiplier = getTotalSignMultiplier(transactionType); + const signMultiplier = getTotalSignMultiplier(transactionStatus); return { productName: product.name, @@ -34,8 +34,8 @@ function reportDataBuilderFactory(transactionStatuses) { } return function (pointOfSaleDataUtils) { - function pickProductCountAction(transactionType) { - return isSaleType(transactionType) + function pickProductCountAction(transactionStatus) { + return isSaleType(transactionStatus) ? pointOfSaleDataUtils.getProductCountBySale : pointOfSaleDataUtils.getProductCountByReturn; } diff --git a/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js b/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js index 2bf3594..e2b1b23 100644 --- a/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js +++ b/jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js @@ -5,15 +5,15 @@ function salesReporterFactory( reportDataBuilderFactory ) { - function getReport(transactionType) { + function getReport(transactionStatus) { const productData = dataLoader.getProductData(); const transactionData = dataLoader.getTransactionData(); - const transactionTypes = dataLoader.getTransactionTypes(); + const transactionStatuses = dataLoader.getTransactionStatuses(); - const pointOfSaleDataUtils = pointOfSaleDataUtilsFactory(transactionTypes); - const reportDataBuilder = reportDataBuilderFactory(transactionTypes)(pointOfSaleDataUtils); + const pointOfSaleDataUtils = pointOfSaleDataUtilsFactory(transactionStatuses); + const reportDataBuilder = reportDataBuilderFactory(transactionStatuses)(pointOfSaleDataUtils); - return reportDataBuilder.buildReportData(transactionType, transactionData, productData); + return reportDataBuilder.buildReportData(transactionStatus, transactionData, productData); } return { diff --git a/test/form-helpers/4_test-dummy-helpers.js b/test/form-helpers/4_test-dummy-helpers.js index a7b3ad5..bb4364e 100644 --- a/test/form-helpers/4_test-dummy-helpers.js +++ b/test/form-helpers/4_test-dummy-helpers.js @@ -55,7 +55,7 @@ const fourthFormHelpers = (function () { function buildTestData(productData, transactionStatuses, transactionData = []) { return { productData: productData, - transactionTypes: transactionStatuses, + transactionStatuses: transactionStatuses, transactionData: transactionData }; } From e7190a0b45d69213556885e18e403b4bcfff6c8a Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:47:56 -0800 Subject: [PATCH 26/63] docs: working on form4 --- .../form4-doc/app/reportDataBuilderFactory.md | 4 +- .../form4-doc/app/salesReporterFactory.md | 24 ++++-- .../form4-doc/getReport/getSalesReport.md | 62 ++++++++++++- docs/TEST-DUMMY-FORM.md | 86 +++++++++++++++++-- 4 files changed, 156 insertions(+), 20 deletions(-) diff --git a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md index 3b06b0a..8be4c15 100644 --- a/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md +++ b/docs-source/forms-source/form4-doc/app/reportDataBuilderFactory.md @@ -75,4 +75,6 @@ The `buildReportData` function returns an array of objects that have the followi quantity, // integer number -- count sold or returned, total of transactionData.quantity total // number -- the sales price for a single item of this product quantity * productDatum.price } -``` \ No newline at end of file +``` + +Each item in the array will represent the results for a different product. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md index 2922762..24fcc70 100644 --- a/docs-source/forms-source/form4-doc/app/salesReporterFactory.md +++ b/docs-source/forms-source/form4-doc/app/salesReporterFactory.md @@ -22,7 +22,7 @@ The `dataLoader` parameter is an object with following shape: { getProductData, getTransactionData, - getTransactionTypes + getTransactionStatuses } ``` @@ -68,15 +68,15 @@ The `getTransactionData` function returns an array of objects that have the foll ##### Get Transaction Types Function ##### -The `getTransactionTypes` function has the following signature: +The `getTransactionStatuses` function has the following signature: ```javascript -getTransactionTypes() +getTransactionStatuses() ``` ###### Get Transaction Types Return Value ###### -The `getTransactionTypes` function returns an object with the following structure: +The `getTransactionStatuses` function returns an object with the following structure: ```javascript { @@ -100,15 +100,21 @@ The `` function returns an object with the following structure: The `getReport` function has the following signature: ```javascript -function getReport(transactionType) +function getReport(transactionStatus) ``` -The `transactionType` parameter is an integer number that maps to Sale or Return as determined by the `transactionTypes` returned from the `getTransactionTypes` function. +The `transactionStatus` parameter is an integer number that maps to Sale or Return as determined by the `transactionStatuses` returned from the `getTransactionStatuses` function. ###### Get Report Return Value ###### -The `getReport` function returns an object with the following structure: +The `getReport` function returns an array of objects with the following structure: ```javascript -// ? -``` \ No newline at end of file +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} +``` + +Each item in the array will represent the results for a different product. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index 971fbf3..db6cac1 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -38,4 +38,64 @@ function salesReporterFactory( ) ``` -You will have to create a fake `dataLoader`, use the `pointOfSaleDataUtilsFactoryBuilder` to get the `pointOfSaleDataUtilsFactory` and simply pass the `reportDataBuilderFactory` that is already available to the test. \ No newline at end of file +You will have to create a fake `dataLoader`. You will also use the `pointOfSaleDataUtilsFactory` and the `reportDataBuilderFactory` that are already available to the test. + +This will return an empty array. + +
dataLoader hints + +The `dataLoader` has 3 functions and the following structure: + +```javascript +{ + getProductData, + getTransactionData, + getTransactionStatuses +} +``` + +The `getProductData` will be set to the `buildProductData` helper function. The `getTransactionStatuses` will be set to the `buildTransactionStatuses` helper function. + +The real odd ball here is the `getTransactionData` which is expected to return an array of transaction records. You will have to create this function, and have it return an empty array. + +
Code + +**Example** + +```javascript + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [], + getTransactionStatuses: buildTransactionStatuses + }; +``` + +
+ +
+ +
Hints + +You just have to pass the values to the function, and capture the returned function. You will then have to call that function with a "Sale" transactionStatus. + +
Code + +```javascript +it('returns an empty object for sale counts if no sale data exists', () => { + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [], + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + let result = getReport(transactionStatuses.Sale); + + assert.deepEqual(result, []); +}); +``` + +
+ +
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 9ad0393..6d42b33 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -181,7 +181,7 @@ The `dataLoader` parameter is an object with following shape: { getProductData, getTransactionData, - getTransactionTypes + getTransactionStatuses } ``` @@ -227,15 +227,15 @@ The `getTransactionData` function returns an array of objects that have the foll ##### Get Transaction Types Function ##### -The `getTransactionTypes` function has the following signature: +The `getTransactionStatuses` function has the following signature: ```javascript -getTransactionTypes() +getTransactionStatuses() ``` ###### Get Transaction Types Return Value ###### -The `getTransactionTypes` function returns an object with the following structure: +The `getTransactionStatuses` function returns an object with the following structure: ```javascript { @@ -259,18 +259,24 @@ The `` function returns an object with the following structure: The `getReport` function has the following signature: ```javascript -function getReport(transactionType) +function getReport(transactionStatus) ``` -The `transactionType` parameter is an integer number that maps to Sale or Return as determined by the `transactionTypes` returned from the `getTransactionTypes` function. +The `transactionStatus` parameter is an integer number that maps to Sale or Return as determined by the `transactionStatuses` returned from the `getTransactionStatuses` function. ###### Get Report Return Value ###### -The `getReport` function returns an object with the following structure: +The `getReport` function returns an array of objects with the following structure: ```javascript -// ? +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} ``` + +Each item in the array will represent the results for a different product. ### Report Data Builder Factory ### @@ -347,6 +353,8 @@ The `buildReportData` function returns an array of objects that have the followi total // number -- the sales price for a single item of this product quantity * productDatum.price } ``` + +Each item in the array will represent the results for a different product. @@ -1405,7 +1413,67 @@ function salesReporterFactory( ) ``` -You will have to create a fake `dataLoader`, use the `pointOfSaleDataUtilsFactoryBuilder` to get the `pointOfSaleDataUtilsFactory` and simply pass the `reportDataBuilderFactory` that is already available to the test. +You will have to create a fake `dataLoader`. You will also use the `pointOfSaleDataUtilsFactory` and the `reportDataBuilderFactory` that are already available to the test. + +This will return an empty array. + +
dataLoader hints + +The `dataLoader` has 3 functions and the following structure: + +```javascript +{ + getProductData, + getTransactionData, + getTransactionStatuses +} +``` + +The `getProductData` will be set to the `buildProductData` helper function. The `getTransactionStatuses` will be set to the `buildTransactionStatuses` helper function. + +The real odd ball here is the `getTransactionData` which is expected to return an array of transaction records. You will have to create this function, and have it return an empty array. + +
Code + +**Example** + +```javascript + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [], + getTransactionStatuses: buildTransactionStatuses + }; +``` + +
+ +
+ +
Hints + +You just have to pass the values to the function, and capture the returned function. You will then have to call that function with a "Sale" transactionStatus. + +
Code + +```javascript +it('returns an empty object for sale counts if no sale data exists', () => { + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [], + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + let result = getReport(transactionStatuses.Sale); + + assert.deepEqual(result, []); +}); +``` + +
+ +
From ecc05a3ce7485c84f0eb809a105df56ceee61a53 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:49:42 -0800 Subject: [PATCH 27/63] docs: fixed some casing --- docs-source/forms-source/form4-doc/getReport/getSalesReport.md | 2 +- docs/TEST-DUMMY-FORM.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index db6cac1..8bc2bb1 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -42,7 +42,7 @@ You will have to create a fake `dataLoader`. You will also use the `pointOfSale This will return an empty array. -
dataLoader hints +
Data Loader Hints The `dataLoader` has 3 functions and the following structure: diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 6d42b33..6de213f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1417,7 +1417,7 @@ You will have to create a fake `dataLoader`. You will also use the `pointOfSale This will return an empty array. -
dataLoader hints +
Data Loader Hints The `dataLoader` has 3 functions and the following structure: From 60a24bb3ac2ad18349f5ce1884130a4f0761b851 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:51:43 -0800 Subject: [PATCH 28/63] docs: indicated that form4 was incomplete --- FORMS.md | 2 +- docs-source/forms-source/forms.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FORMS.md b/FORMS.md index e5bf91f..4166edc 100644 --- a/FORMS.md +++ b/FORMS.md @@ -13,7 +13,7 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) +3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ diff --git a/docs-source/forms-source/forms.md b/docs-source/forms-source/forms.md index bfe5bb5..8e5f7e9 100644 --- a/docs-source/forms-source/forms.md +++ b/docs-source/forms-source/forms.md @@ -7,4 +7,4 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) \ No newline at end of file +3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ \ No newline at end of file From 6aff14c0f9dfe2738e6a07ed9ccd687237fb83a6 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:53:01 -0800 Subject: [PATCH 29/63] docs: indicating all the forms to be documented --- FORMS.md | 2 ++ docs-source/forms-source/forms.md | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/FORMS.md b/FORMS.md index 4166edc..ab2032c 100644 --- a/FORMS.md +++ b/FORMS.md @@ -14,6 +14,8 @@ 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) 3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ +4. Async Form _TBD_ +5. Async Test Dummy Form _TBD_ diff --git a/docs-source/forms-source/forms.md b/docs-source/forms-source/forms.md index 8e5f7e9..1f4b9b6 100644 --- a/docs-source/forms-source/forms.md +++ b/docs-source/forms-source/forms.md @@ -7,4 +7,6 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ \ No newline at end of file +3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ +4. Async Form _TBD_ +5. Async Test Dummy Form _TBD_ \ No newline at end of file From 9f1fddb3e5480e6a639d8fb60a2840989d15d731 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 09:57:58 -0800 Subject: [PATCH 30/63] docs: added files to app docs --- docs-source/forms-source/form4-doc/app/_main.md | 1 + docs-source/forms-source/form4-doc/app/importantFiles.md | 8 ++++++++ docs/TEST-DUMMY-FORM.md | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 docs-source/forms-source/form4-doc/app/importantFiles.md diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md index 06afc43..884ff36 100644 --- a/docs-source/forms-source/form4-doc/app/_main.md +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -7,6 +7,7 @@ The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. + +> jsforms-source/4_test-dummy-form/sales-reporter/[salesReporterFactory.js](../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js) +> jsforms-source/4_test-dummy-form/pos-transaction-services/[reportDataBuilder.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js) \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 6de213f..fe52fa2 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -44,6 +44,12 @@ This section is doable without the hints. it is _hard_ but doable. However, the The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. +### Sales Report App — Important Files ### + +> jsforms-source/4_test-dummy-form/sales-reporter/[salesReporterFactory.js](../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js) +> jsforms-source/4_test-dummy-form/pos-transaction-services/[reportDataBuilder.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js) + + ### Point Of Sale Data Utility Factory Builder ### File: [/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js](../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js) From d90abb66a97c0081f6ca88f5c7b838df150c685d Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 12:13:50 -0800 Subject: [PATCH 31/63] docs: updating form4 --- .../form4-doc/getReport/getSalesReport.md | 15 ++++++++++++--- docs/TEST-DUMMY-FORM.md | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index 8bc2bb1..c32769d 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -15,9 +15,6 @@ Now when you write each test, you will follow the process you did before with on 1. Enable the test 2. Add guide comments - 1. Arrange - 2. Act - 3. Assert 3. Implement the arrange 4. Implement the act 5. Implement the assert @@ -42,6 +39,18 @@ You will have to create a fake `dataLoader`. You will also use the `pointOfSale This will return an empty array. +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +
Data Loader Hints The `dataLoader` has 3 functions and the following structure: diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index fe52fa2..372fcf1 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1396,9 +1396,6 @@ Now when you write each test, you will follow the process you did before with on 1. Enable the test 2. Add guide comments - 1. Arrange - 2. Act - 3. Assert 3. Implement the arrange 4. Implement the act 5. Implement the assert @@ -1423,6 +1420,18 @@ You will have to create a fake `dataLoader`. You will also use the `pointOfSale This will return an empty array. +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +
Data Loader Hints The `dataLoader` has 3 functions and the following structure: From 7531032c00c07a79dce2447a4f4d13ca6328d5c4 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 13:09:00 -0800 Subject: [PATCH 32/63] docs: form 4 --- .../form4-doc/getReport/getSalesReport.md | 247 ++++++++++++++++++ docs/TEST-DUMMY-FORM.md | 247 ++++++++++++++++++ 2 files changed, 494 insertions(+) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index c32769d..3774c71 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -91,6 +91,7 @@ You just have to pass the values to the function, and capture the returned funct ```javascript it('returns an empty object for sale counts if no sale data exists', () => { + // Arrange let dataLoader = { getProductData: buildProductData, getTransactionData: () => [], @@ -99,12 +100,258 @@ it('returns an empty object for sale counts if no sale data exists', () => { let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + // Act let result = getReport(transactionStatuses.Sale); + // Assert assert.deepEqual(result, []); }); ```
+
+ +#### It returns a sales report with one sale #### + +Okay, the last test did a lot of heavy lifting for you. Now you will test the `getReport` function for a sales report with only one item sold. + +The biggest change between this test and the previous one is that the `getTransactionData` needs to return a single transaction record that has a `quantity` of `1`. + +The `getReport` function will return an array containing a single object with the following structure: + +```javascript +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} +``` + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +
Arrange Hints + +You are going to setup the `dataLoader` the same way as you did before. But again the odd item out is the `getTransactionData` function because this needs to return an array with a single transaction record for a sale. + +The key here is that the transaction record `productId` needs to match one of the products returned from `getProductData`. The `transactionStatus` needs to match the `Sale` property on the `transactionStatuses` object. You will need to use the `buildTransactionRecord` function to create this record. + +
Code + +**Example** + +```javascript +// Arrange +let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ], + getTransactionStatuses: buildTransactionStatuses +}; + +let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); +``` + +
+ +
+ +
Hints + +Once you have the `dataLoader` created, you will need to only change the Assert part of the code. Remember the `total` in the result is the product's `price`. + +
Code + +**Example** + +```javascript +it('returns a sales report with one sale', () => { + // Arrange + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ], + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + // Act + let result = getReport(transactionStatuses.Sale); + + // Assert + assert.deepEqual(result, [{ + productName: ?, + quantity: ?, + total: ? + }]); +}); +``` + +
+ +
+ +#### Refactor Sales Report Tests #### + +You have introduced a lot of duplication. And moreover the duplication in the "Arrange" part of your tests is most likely needed for the rest of the tests. As such, it is time you simplify your tests. + +A lot of JavaScript test frameworks use a construct called `beforeEach` that creates a function that is run just before each test. This allows you to setup common variables. These variables will be test suite scoped variables. + +> **
WARNING
** +> +>
You must be careful when using a test suite scoped variables as you can accidentally cause one test to effect another. To prevent this, you must reset all such variables to an initial value in the beforeEach.
+ +##### Refactor Sales Report Tests Create the Before Each ##### + +You need to create the `getReport` function in the `beforeEach` section. However, in order for this to work you will also need to create and assign a variable to hold the transaction records. This way you can add an item to it in the second test. + +
Hints + +You will need to create two variables before the "get sales report" section. One to hold the `getReport` function and the other to hold the transaction records. + +Bellow those, but still before the "get sales report" section, you will need to create the `beforeEach` section. + +
Code + +**Example** + +```javascript + describe('get report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js + + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { +``` + +
+ +
+ +##### Refactor Sales Report Tests Modify the First Test ##### + +You need to change the first test, "returns a sales report with no sales", so that it uses the new suite level variables. + +
Hints + +The whole arrange is now being done in the `beforeEach`. So delete that and use the variable that is holding the `getReport` function. + +
Code + +**Example** + +```javascript + describe('get report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js + + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { + it('returns an empty object for sale counts if no sale data exists', () => { + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, []); + }); +``` + +
+ +
+ +##### Refactor Sales Report Tests Modify the Second Test ##### + +The second test has more to it. You still have an arrange that is specific to the test. You need to add the transaction record to the variable used to store the transaction records. You might be able to use the [`Array.prototype.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) method. + +
Hints + +Most of the arrange in this test can be deleted. You will just need to add the sales transaction record to the array before calling the `getReport` function. + +
Code + +**Example** + +```javascript + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { + + // ... + + it('returns a sales report with one sale', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, 1)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [{ + productName: ?, + quantity: ?, + total: ? + }]); + }); +``` + +
+
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 372fcf1..4e590a3 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1472,6 +1472,7 @@ You just have to pass the values to the function, and capture the returned funct ```javascript it('returns an empty object for sale counts if no sale data exists', () => { + // Arrange let dataLoader = { getProductData: buildProductData, getTransactionData: () => [], @@ -1480,8 +1481,10 @@ it('returns an empty object for sale counts if no sale data exists', () => { let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + // Act let result = getReport(transactionStatuses.Sale); + // Assert assert.deepEqual(result, []); }); ``` @@ -1489,6 +1492,250 @@ it('returns an empty object for sale counts if no sale data exists', () => {
+ +#### It returns a sales report with one sale #### + +Okay, the last test did a lot of heavy lifting for you. Now you will test the `getReport` function for a sales report with only one item sold. + +The biggest change between this test and the previous one is that the `getTransactionData` needs to return a single transaction record that has a `quantity` of `1`. + +The `getReport` function will return an array containing a single object with the following structure: + +```javascript +{ + productName, // string -- Name of product, from productDatum.Name + quantity, // integer number -- count sold or returned, total of transactionData.quantity + total // number -- the sales price for a single item of this product quantity * productDatum.price +} +``` + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments + +
Arrange Hints + +You are going to setup the `dataLoader` the same way as you did before. But again the odd item out is the `getTransactionData` function because this needs to return an array with a single transaction record for a sale. + +The key here is that the transaction record `productId` needs to match one of the products returned from `getProductData`. The `transactionStatus` needs to match the `Sale` property on the `transactionStatuses` object. You will need to use the `buildTransactionRecord` function to create this record. + +
Code + +**Example** + +```javascript +// Arrange +let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ], + getTransactionStatuses: buildTransactionStatuses +}; + +let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); +``` + +
+ +
+ +
Hints + +Once you have the `dataLoader` created, you will need to only change the Assert part of the code. Remember the `total` in the result is the product's `price`. + +
Code + +**Example** + +```javascript +it('returns a sales report with one sale', () => { + // Arrange + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => [ + buildTransactionRecord(?, transactionStatuses.Sale, 1) + ], + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + // Act + let result = getReport(transactionStatuses.Sale); + + // Assert + assert.deepEqual(result, [{ + productName: ?, + quantity: ?, + total: ? + }]); +}); +``` + +
+ +
+ +#### Refactor Sales Report Tests #### + +You have introduced a lot of duplication. And moreover the duplication in the "Arrange" part of your tests is most likely needed for the rest of the tests. As such, it is time you simplify your tests. + +A lot of JavaScript test frameworks use a construct called `beforeEach` that creates a function that is run just before each test. This allows you to setup common variables. These variables will be test suite scoped variables. + +> **
WARNING
** +> +>
You must be careful when using a test suite scoped variables as you can accidentally cause one test to effect another. To prevent this, you must reset all such variables to an initial value in the beforeEach.
+ +##### Refactor Sales Report Tests Create the Before Each ##### + +You need to create the `getReport` function in the `beforeEach` section. However, in order for this to work you will also need to create and assign a variable to hold the transaction records. This way you can add an item to it in the second test. + +
Hints + +You will need to create two variables before the "get sales report" section. One to hold the `getReport` function and the other to hold the transaction records. + +Bellow those, but still before the "get sales report" section, you will need to create the `beforeEach` section. + +
Code + +**Example** + +```javascript + describe('get report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js + + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { +``` + +
+ +
+ +##### Refactor Sales Report Tests Modify the First Test ##### + +You need to change the first test, "returns a sales report with no sales", so that it uses the new suite level variables. + +
Hints + +The whole arrange is now being done in the `beforeEach`. So delete that and use the variable that is holding the `getReport` function. + +
Code + +**Example** + +```javascript + describe('get report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js + + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { + it('returns an empty object for sale counts if no sale data exists', () => { + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, []); + }); +``` + +
+ +
+ +##### Refactor Sales Report Tests Modify the Second Test ##### + +The second test has more to it. You still have an arrange that is specific to the test. You need to add the transaction record to the variable used to store the transaction records. You might be able to use the [`Array.prototype.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) method. + +
Hints + +Most of the arrange in this test can be deleted. You will just need to add the sales transaction record to the array before calling the `getReport` function. + +
Code + +**Example** + +```javascript + let reportBuilder; + let transactionRecords; + + beforeEach(() => { + transactionRecords = []; + let dataLoader = { + getProductData: buildProductData, + getTransactionData: () => transactionRecords, + getTransactionStatuses: buildTransactionStatuses + }; + + let { getReport } = + salesReporterFactory(dataLoader, pointOfSaleDataUtilsFactory, reportDataBuilderFactory); + + reportBuilder = getReport; + }); + + describe('get sales report', function () { + + // ... + + it('returns a sales report with one sale', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, 1)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [{ + productName: ?, + quantity: ?, + total: ? + }]); + }); +``` + +
+ +
From 1eec2ae908d00a08860e03851a951147e56aced0 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Wed, 22 Feb 2023 14:59:58 -0800 Subject: [PATCH 33/63] docs: more form4 --- .../form4-doc/getReport/getSalesReport.md | 55 +++++++++++++++++++ docs/TEST-DUMMY-FORM.md | 55 +++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index 3774c71..efdcae9 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -354,4 +354,59 @@ Most of the arrange in this test can be deleted. You will just need to add the s
+
+ +#### It returns a sales report with two sales of different products #### + +Now you will test that the `getReport` can return a report with two different products. + +This will look very similar to the above test, but you will need to add two products, with different quantities to the transaction records. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +Add the two different products to the transaction records. Make sure that the `productId` of each maps to a product that is returned by the `buildProductData` function. You will also want each product to have a different non-one `quantity` value. + +You will also have two objects in the result to test for. + +
Code + +**Example** + +```javascript +it('returns a sales report with two sales of the same product', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the second product ID + quantity: ?, // The quantity of the second transaction record + total: ? // the price from the second product multiplied by te quantity + }, + ]); +}); +``` + +
+
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 4e590a3..1e5001f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1736,6 +1736,61 @@ Most of the arrange in this test can be deleted. You will just need to add the s + +#### It returns a sales report with two sales of different products #### + +Now you will test that the `getReport` can return a report with two different products. + +This will look very similar to the above test, but you will need to add two products, with different quantities to the transaction records. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +Add the two different products to the transaction records. Make sure that the `productId` of each maps to a product that is returned by the `buildProductData` function. You will also want each product to have a different non-one `quantity` value. + +You will also have two objects in the result to test for. + +
Code + +**Example** + +```javascript +it('returns a sales report with two sales of the same product', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the second product ID + quantity: ?, // The quantity of the second transaction record + total: ? // the price from the second product multiplied by te quantity + }, + ]); +}); +``` + +
+ +
From 97330d624f4444fc64f62a2aa89859307e4601ff Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:14:51 -0800 Subject: [PATCH 34/63] docs: more form4 --- .../form4-doc/getReport/getSalesReport.md | 53 ++++++++++++++++++- docs/TEST-DUMMY-FORM.md | 53 ++++++++++++++++++- 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index efdcae9..0c43867 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -386,7 +386,7 @@ You will also have two objects in the result to test for. **Example** ```javascript -it('returns a sales report with two sales of the same product', () => { +it('returns a sales report with two sales of different products', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); @@ -401,7 +401,56 @@ it('returns a sales report with two sales of the same product', () => { { productName: ?, // The name that maps to the second product ID quantity: ?, // The quantity of the second transaction record - total: ? // the price from the second product multiplied by te quantity + total: ? // the price from the second product multiplied by the quantity + }, + ]); +}); +``` + + + + + +#### It returns a sales report with two sales of the same product #### + +You will test what happens if the transaction records have two different transactions for the sale of the same product. The result should represent the total of the quantity. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +This test will look very similar to the above with the difference that the two transaction records will share the same `productId`. + +There will only be a single object in the result. + +
Code + +**Example** + +```javascript +it('returns a sales report with no "returns" data', () => { + let productId = ?; + transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the product ID + quantity: ?, // The total quantity of the transaction records + total: ? // the price from the product multiplied by the total quantity }, ]); }); diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 1e5001f..3a0f179 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1767,7 +1767,7 @@ You will also have two objects in the result to test for. **Example** ```javascript -it('returns a sales report with two sales of the same product', () => { +it('returns a sales report with two sales of different products', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); @@ -1782,7 +1782,56 @@ it('returns a sales report with two sales of the same product', () => { { productName: ?, // The name that maps to the second product ID quantity: ?, // The quantity of the second transaction record - total: ? // the price from the second product multiplied by te quantity + total: ? // the price from the second product multiplied by the quantity + }, + ]); +}); +``` + +
+ +
+ +#### It returns a sales report with two sales of the same product #### + +You will test what happens if the transaction records have two different transactions for the sale of the same product. The result should represent the total of the quantity. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +This test will look very similar to the above with the difference that the two transaction records will share the same `productId`. + +There will only be a single object in the result. + +
Code + +**Example** + +```javascript +it('returns a sales report with no "returns" data', () => { + let productId = ?; + transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the product ID + quantity: ?, // The total quantity of the transaction records + total: ? // the price from the product multiplied by the total quantity }, ]); }); From 63672f10e59f13f7cf93eecc280a01ee65a1ca67 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:30:11 -0800 Subject: [PATCH 35/63] docs: finished get sales report form4 --- .../form4-doc/getReport/getSalesReport.md | 56 ++++++++++++++++++- docs/TEST-DUMMY-FORM.md | 56 ++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index 0c43867..61f51d9 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -439,7 +439,7 @@ There will only be a single object in the result. **Example** ```javascript -it('returns a sales report with no "returns" data', () => { +it('returns a sales report with two sales of the same product', () => { let productId = ?; transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); @@ -458,4 +458,58 @@ it('returns a sales report with no "returns" data', () => {
+
+ +#### It returns a sales report with no "returns" data #### + +Now, you will verify that the `getReport` function filters according to the Sale transaction status. + +You will want to create a number of sale transactions, at least 3 across at least two products, with one or more return transactions mixed into the bunch. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +You are going to create the test very similarly to two tests ago, but you will add a new transaction record that has the `transactionStatus` equal to Return. + +
Code + +**Example** + +```javascript +it('returns a sales report with no "returns" data', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); // This is the record that is not going to be counted + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the third product ID + quantity: ?, // The quantity of the third transaction record + total: ? // the price from the third product multiplied by the quantity + }, + ]); +}); +``` + +
+
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 3a0f179..cabfddd 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1820,7 +1820,7 @@ There will only be a single object in the result. **Example** ```javascript -it('returns a sales report with no "returns" data', () => { +it('returns a sales report with two sales of the same product', () => { let productId = ?; transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); @@ -1840,6 +1840,60 @@ it('returns a sales report with no "returns" data', () => { + +#### It returns a sales report with no "returns" data #### + +Now, you will verify that the `getReport` function filters according to the Sale transaction status. + +You will want to create a number of sale transactions, at least 3 across at least two products, with one or more return transactions mixed into the bunch. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +You are going to create the test very similarly to two tests ago, but you will add a new transaction record that has the `transactionStatus` equal to Return. + +
Code + +**Example** + +```javascript +it('returns a sales report with no "returns" data', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); // This is the record that is not going to be counted + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); + + let result = reportBuilder(transactionStatuses.Sale); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the third product ID + quantity: ?, // The quantity of the third transaction record + total: ? // the price from the third product multiplied by the quantity + }, + ]); +}); +``` + +
+ +
From e6284906f6c78f66544ad4ff6a9c2b2ca6324a4b Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:32:26 -0800 Subject: [PATCH 36/63] docs: setup get returns report form4 --- docs-source/forms-source/form4-doc/getReport/_main.md | 1 + .../forms-source/form4-doc/getReport/getReturnsReport.md | 6 ++++++ docs/TEST-DUMMY-FORM.md | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 docs-source/forms-source/form4-doc/getReport/getReturnsReport.md diff --git a/docs-source/forms-source/form4-doc/getReport/_main.md b/docs-source/forms-source/form4-doc/getReport/_main.md index fb4a80a..71055e6 100644 --- a/docs-source/forms-source/form4-doc/getReport/_main.md +++ b/docs-source/forms-source/form4-doc/getReport/_main.md @@ -10,4 +10,5 @@ The `getReport` function can either create a Sales report or a Returns report. \ No newline at end of file diff --git a/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md new file mode 100644 index 0000000..d9a1a54 --- /dev/null +++ b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md @@ -0,0 +1,6 @@ + +TBD \ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index cabfddd..b6dac04 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1895,6 +1895,10 @@ it('returns a sales report with no "returns" data', () => { + +### Get Returns Report ### +TBD + ## TDB ## From 1ad7d0847b7ecc3b58b810e71426ad251f5716cf Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:42:12 -0800 Subject: [PATCH 37/63] docs: finished get returns report form4 --- .../form4-doc/getReport/getReturnsReport.md | 64 ++++++++++++++++++- docs/TEST-DUMMY-FORM.md | 64 ++++++++++++++++++- 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md index d9a1a54..51e8706 100644 --- a/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md @@ -3,4 +3,66 @@ (title "Get Returns Report") ) /bl--> -TBD \ No newline at end of file + +There is little to do in testing the "Returns" report because if you look at the code, it is almost entirely the same code as what creates the "Sales" report. So the only thing we have to do is test that it correctly filters when we ask for a report of the "Returns". + +#### It returns a "returns" report with no "sales" data #### + +You will now create a test that will verify that the report is correct when you ask for it to give you a report of the returns. + +You will want at least three different transactions records that are composed of at least two different product IDs. You will want one of those records to be a Sale and the rest to be Returns. + +You will then verify that the resulting object has the correct products, quantities, and prices. + +Remember to pass `transactionStatuses.Return` to the `getReport` function. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +This will look very much like the last test but the transaction statuses are swapped. + +
Code + +**Example** + +```javascript +describe('get returns report', function () { + it('returns a "returns" report with no "sales" data', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); // This is the record that is not going to be counted + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); + + let result = reportBuilder(transactionStatuses.Return); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the third product ID + quantity: ?, // The quantity of the third transaction record + total: ? // the price from the third product multiplied by the quantity + }, + ]); + + }); +}); +``` + +
+ +
\ No newline at end of file diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index b6dac04..04437ea 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -1897,7 +1897,69 @@ it('returns a sales report with no "returns" data', () => { ### Get Returns Report ### -TBD + +There is little to do in testing the "Returns" report because if you look at the code, it is almost entirely the same code as what creates the "Sales" report. So the only thing we have to do is test that it correctly filters when we ask for a report of the "Returns". + +#### It returns a "returns" report with no "sales" data #### + +You will now create a test that will verify that the report is correct when you ask for it to give you a report of the returns. + +You will want at least three different transactions records that are composed of at least two different product IDs. You will want one of those records to be a Sale and the rest to be Returns. + +You will then verify that the resulting object has the correct products, quantities, and prices. + +Remember to pass `transactionStatuses.Return` to the `getReport` function. + +To write this test follow these steps. + +1. Enable the test +2. Add guide comments + 1. Arrange + 2. Act + 3. Assert +3. Implement the arrange +4. Implement the act +5. Implement the assert +6. Remove Guide comments +7. Refactor code if possible + +
Hints + +This will look very much like the last test but the transaction statuses are swapped. + +
Code + +**Example** + +```javascript +describe('get returns report', function () { + it('returns a "returns" report with no "sales" data', () => { + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); // This is the record that is not going to be counted + transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); + + let result = reportBuilder(transactionStatuses.Return); + + assert.deepEqual(result, [ + { + productName: ?, // The name that maps to the first product ID + quantity: ?, // The quantity of the first transaction record + total: ? // the price from the first product multiplied by te quantity + }, + { + productName: ?, // The name that maps to the third product ID + quantity: ?, // The quantity of the third transaction record + total: ? // the price from the third product multiplied by the quantity + }, + ]); + + }); +}); +``` + +
+ +
From 3d485a280eacbf3de90d924a62d44a81aabf24f3 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:43:00 -0800 Subject: [PATCH 38/63] docs: finished form4 --- FORMS.md | 6 +++--- docs-source/forms-source/forms.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/FORMS.md b/FORMS.md index ab2032c..b33100b 100644 --- a/FORMS.md +++ b/FORMS.md @@ -13,9 +13,9 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ -4. Async Form _TBD_ -5. Async Test Dummy Form _TBD_ +4. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) +5. Async Form _TBD_ +6. Async Test Dummy Form _TBD_ diff --git a/docs-source/forms-source/forms.md b/docs-source/forms-source/forms.md index 1f4b9b6..779940e 100644 --- a/docs-source/forms-source/forms.md +++ b/docs-source/forms-source/forms.md @@ -7,6 +7,6 @@ 1. [First Form](./docs/FIRST-FORM.md) 2. [Second Form](./docs/SECOND-FORM.md) 3. [Third Form](./docs/THIRD-FORM.md) -3. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) _Incomplete_ -4. Async Form _TBD_ -5. Async Test Dummy Form _TBD_ \ No newline at end of file +4. [Test Dummy Form](./docs/TEST-DUMMY-FORM.md) +5. Async Form _TBD_ +6. Async Test Dummy Form _TBD_ \ No newline at end of file From f7d584b42e44b48394d341ec845988822c2a0b0b Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 09:46:10 -0800 Subject: [PATCH 39/63] docs: marking form4 complete --- README.md | 2 +- .../main-sections/subsections/using-jsl/solving-each-form.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d25d55d..c5f3324 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ For a video walkthrough of the setup process, check out the following video: 4. Third Form -- Update code to pass new tests, keep tests old green 1. [Third Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) 5. Test Dummy Form (Fourth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) - 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) **Incomplete** + 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) 6. Async Form -- Write code to pass each test; don't forget the refactoring steps! 1. Documentation TBD 7. Async Test Dummy Form (Sixth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) diff --git a/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md b/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md index 24bde24..b1b2b0c 100644 --- a/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md +++ b/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md @@ -11,7 +11,7 @@ 4. Third Form -- Update code to pass new tests, keep tests old green 1. [Third Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) 5. Test Dummy Form (Fourth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) - 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) **Incomplete** + 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) 6. Async Form -- Write code to pass each test; don't forget the refactoring steps! 1. Documentation TBD 7. Async Test Dummy Form (Sixth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) From adbfa4d21c46f30911a06e201bd9d0213cc58b0e Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 10:04:39 -0800 Subject: [PATCH 40/63] docs: added senpl as contributor --- .all-contributorsrc | 9 +++++++++ README.md | 1 + docs-source/readme-source/main-sections/thanks.md | 1 + 3 files changed, 11 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b592af0..295481b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -37,6 +37,15 @@ "code", "doc" ] + }, + { + "login": "senpl", + "name": "Michał Urbanek", + "avatar_url": "https://avatars.githubusercontent.com/u/5415941?v=4", + "profile": "https://github.com/senpl", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index c5f3324..573ac74 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,7 @@ This section will be updated as forms are completed and ready for use. hunterinderstries
hunterinderstries

💵 EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 + Michał Urbanek
Michał Urbanek

💻 diff --git a/docs-source/readme-source/main-sections/thanks.md b/docs-source/readme-source/main-sections/thanks.md index c0b1424..770f23d 100644 --- a/docs-source/readme-source/main-sections/thanks.md +++ b/docs-source/readme-source/main-sections/thanks.md @@ -15,6 +15,7 @@ hunterinderstries
hunterinderstries

💵 EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 + Michał Urbanek
Michał Urbanek

💻 From 4211c27e254fd41b4bd064a4e790f476ada34981 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 10:08:22 -0800 Subject: [PATCH 41/63] docs: fixed senpl's contributions --- .all-contributorsrc | 2 +- README.md | 2 +- docs-source/readme-source/main-sections/thanks.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 295481b..7893fc0 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -44,7 +44,7 @@ "avatar_url": "https://avatars.githubusercontent.com/u/5415941?v=4", "profile": "https://github.com/senpl", "contributions": [ - "code" + "bug" ] } ], diff --git a/README.md b/README.md index 573ac74..d265bc0 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ This section will be updated as forms are completed and ready for use. hunterinderstries
hunterinderstries

💵 EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 - Michał Urbanek
Michał Urbanek

💻 + Michał Urbanek
Michał Urbanek

🐛 diff --git a/docs-source/readme-source/main-sections/thanks.md b/docs-source/readme-source/main-sections/thanks.md index 770f23d..8041fba 100644 --- a/docs-source/readme-source/main-sections/thanks.md +++ b/docs-source/readme-source/main-sections/thanks.md @@ -15,7 +15,7 @@ hunterinderstries
hunterinderstries

💵 EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 - Michał Urbanek
Michał Urbanek

💻 + Michał Urbanek
Michał Urbanek

🐛 From 48609bec90fc478481d20c37b5ca173d3449a94e Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 10:13:18 -0800 Subject: [PATCH 42/63] docs: added willemlarsen to contribs --- .all-contributorsrc | 9 +++++++++ README.md | 1 + docs-source/readme-source/main-sections/thanks.md | 1 + 3 files changed, 11 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 7893fc0..0a9bab5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -46,6 +46,15 @@ "contributions": [ "bug" ] + }, + { + "login": "willemlarsen", + "name": "Willem Larsen", + "avatar_url": "https://avatars.githubusercontent.com/u/3875136?v=4", + "profile": "http://thermodynamicsofemotion.com/", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, diff --git a/README.md b/README.md index d265bc0..0fd7665 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ This section will be updated as forms are completed and ready for use. EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 Michał Urbanek
Michał Urbanek

🐛 + Willem Larsen
Willem Larsen

💻 diff --git a/docs-source/readme-source/main-sections/thanks.md b/docs-source/readme-source/main-sections/thanks.md index 8041fba..4230316 100644 --- a/docs-source/readme-source/main-sections/thanks.md +++ b/docs-source/readme-source/main-sections/thanks.md @@ -16,6 +16,7 @@ EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 Michał Urbanek
Michał Urbanek

🐛 + Willem Larsen
Willem Larsen

💻 From ec4234579b57f5e3257a51451ae1f94b3703ac88 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 10:15:17 -0800 Subject: [PATCH 43/63] docs: fixed willemlarsen contrib --- .all-contributorsrc | 2 +- README.md | 2 +- docs-source/readme-source/main-sections/thanks.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0a9bab5..64806ba 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -53,7 +53,7 @@ "avatar_url": "https://avatars.githubusercontent.com/u/3875136?v=4", "profile": "http://thermodynamicsofemotion.com/", "contributions": [ - "code" + "doc" ] } ], diff --git a/README.md b/README.md index 0fd7665..4c7f528 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ This section will be updated as forms are completed and ready for use. EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 Michał Urbanek
Michał Urbanek

🐛 - Willem Larsen
Willem Larsen

💻 + Willem Larsen
Willem Larsen

📖 diff --git a/docs-source/readme-source/main-sections/thanks.md b/docs-source/readme-source/main-sections/thanks.md index 4230316..daa8398 100644 --- a/docs-source/readme-source/main-sections/thanks.md +++ b/docs-source/readme-source/main-sections/thanks.md @@ -16,7 +16,7 @@ EDF Renewables
EDF Renewables

💵 Jason Kerney
Jason Kerney

💻 📖 Michał Urbanek
Michał Urbanek

🐛 - Willem Larsen
Willem Larsen

💻 + Willem Larsen
Willem Larsen

📖 From c1c9dcc3808e028be8dd40a039104181a6b426af Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 11:02:14 -0800 Subject: [PATCH 44/63] docs: fixed type-o in comments --- .reset-files/6_async-test-dummy-form.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.reset-files/6_async-test-dummy-form.test.js b/.reset-files/6_async-test-dummy-form.test.js index a2ea074..5811b80 100644 --- a/.reset-files/6_async-test-dummy-form.test.js +++ b/.reset-files/6_async-test-dummy-form.test.js @@ -83,7 +83,7 @@ describe('Test Dummy Form', function () { // To fix this issue you will need to understand how the Mockery // library works. The beforeEach at the very top of this test will // give you a place to start. - // Assert has a method "doesNothThrow." This would be quite useful here + // Assert has a method "doesNotThrow." This would be quite useful here it('should not throw error immediately when called'); // Sinon is a library built for handling cases where you want to get a view From fd137be3888d939f810db197d0f9ab66f86f5ff8 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 14:48:39 -0800 Subject: [PATCH 45/63] docs: link to docs points to oner's repo --- README.md | 10 +++++----- .../subsections/using-jsl/solving-each-form.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4c7f528..a6cf0c5 100644 --- a/README.md +++ b/README.md @@ -79,15 +79,15 @@ For a video walkthrough of the setup process, check out the following video: ### Solving Each Form ### -1. [Documentation For all Forms](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/FORMS.md) +1. [Documentation For all Forms](https://github.com/cmstead/jsLearnerForms/blob/documentation/FORMS.md) 2. First Form -- Write code to pass each test - 1. [First Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/FIRST-FORM.md) + 1. [First Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/FIRST-FORM.md) 3. Second Form -- Update code to pass new tests, keep old tests green - 1. [Second Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/SECOND-FORM.md) + 1. [Second Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/SECOND-FORM.md) 4. Third Form -- Update code to pass new tests, keep tests old green - 1. [Third Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) + 1. [Third Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) 5. Test Dummy Form (Fourth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) - 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) + 1. [Test Dummy Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) 6. Async Form -- Write code to pass each test; don't forget the refactoring steps! 1. Documentation TBD 7. Async Test Dummy Form (Sixth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) diff --git a/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md b/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md index b1b2b0c..1555b08 100644 --- a/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md +++ b/docs-source/readme-source/main-sections/subsections/using-jsl/solving-each-form.md @@ -3,15 +3,15 @@ (title "Solving Each Form") ) /bl--> -1. [Documentation For all Forms](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/FORMS.md) +1. [Documentation For all Forms](https://github.com/cmstead/jsLearnerForms/blob/documentation/FORMS.md) 2. First Form -- Write code to pass each test - 1. [First Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/FIRST-FORM.md) + 1. [First Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/FIRST-FORM.md) 3. Second Form -- Update code to pass new tests, keep old tests green - 1. [Second Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/SECOND-FORM.md) + 1. [Second Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/SECOND-FORM.md) 4. Third Form -- Update code to pass new tests, keep tests old green - 1. [Third Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) + 1. [Third Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/THIRD-FORM.md) 5. Test Dummy Form (Fourth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) - 1. [Test Dummy Form Documentation](https://github.com/jason-kerney/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) + 1. [Test Dummy Form Documentation](https://github.com/cmstead/jsLearnerForms/blob/documentation/docs/TEST-DUMMY-FORM.md) 6. Async Form -- Write code to pass each test; don't forget the refactoring steps! 1. Documentation TBD 7. Async Test Dummy Form (Sixth Form) -- Write tests matching each description and get all of the code under test (modify ONLY the test code) From ec58cb2021f58167b7ddb26ce623b62b09e7dca2 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Thu, 23 Feb 2023 14:53:04 -0800 Subject: [PATCH 46/63] docs: starting to break form1:variables --- docs-source/forms-source/form1-doc/_main.md | 2 +- .../forms-source/form1-doc/{variables.md => variables/_main.md} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs-source/forms-source/form1-doc/{variables.md => variables/_main.md} (100%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 676a4d1..1a025c1 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -12,7 +12,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 -You will explore the creation and use of variables. - -### declaration and initialization - -Here you will declare and initialize variables. - -#### It should have a variable called "a" - -Create a variable at the top of the block called "a". You will need to use `let` or `var`. - -
Hints - -Be sure you use "var" or "let" to declare your variable - -
Code - -**Example 1** - -```javascript -const jsforms = (function () { - 'use strict'; - let ?; - - return { - }; -})(); -``` - -**Example 2** - -```javascript -const jsforms = (function () { - 'use strict'; - var ?; - - return { - }; -})(); -``` - -
- -
- -#### It should initialize "a" with the value 5 - -Set the initial value of a to 5. - -
Hints - -Initialize a variable with equals: `var a = ...` - -
Code - -**Example 1** - -```javascript -const jsforms = (function () { - 'use strict'; - let a = ?; - - return { - }; -})(); -``` - -**Example 2** - -```javascript -const jsforms = (function () { - 'use strict'; - var a = ?; - - return { - }; -})(); -``` - -
- -
- -### assignment and operators - -Now that you have a variable you will assign it a value different then what it was initialized with. - -#### It should assign the sum of 3 and 7 (3 + 7) to "a" - -Now assign variable `a` with the value of `3 + 7`. - -
Hints - -Add two numbers using the plus (+) operator - -
Code - -**Example 1** - -```javascript - let a = 5; - a = ? + ?; - - return { - }; -``` - -**Example 2** - -```javascript - var a = 5; - a = ? + ?; - - return { - }; -``` -
- -
- -#### It should have a variable "b" initialized to "Hello, World!" - -Create a variable called `b` and initialize it with the value `"Hello, World!" - -
Hints - -Initialize a variable with equals: `var b = ...` - -
Code - -**Example 1** - -```javascript - let b = ?; - - return { - }; -``` - -**Example 2** - -```javascript - var b = ?; - - return { - }; -``` - -
- -
- -### method call - -YOu will make a call to a method on an object. - -#### It should log variable "b" to the console - -Use the `console.log` method to log the value contained in variable `b` to the console. - -
Hints - -Console.log might be just the ticket... - -
Code - -**Example 1** - -```javascript - console.log(?); - - return { - }; -``` - -**Example 2** - -```javascript - console.log(?); - - return { - }; -``` - -
- -
- -### exposing values - -You well now expose values to the outside world. - -#### It should expose variable "b" to be read outside of the module - -Expose the variable `b` to the outside world, by adding it the the object being exported. - -
Hints - -Find `return {};` add a "b" -> `return {b};` - -
Code - -**Example** - -```javascript - return { - ?, - }; -``` - -
- -
\ No newline at end of file +You will explore the creation and use of variables. + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/variables/assignment.md b/docs-source/forms-source/form1-doc/variables/assignment.md new file mode 100644 index 0000000..a2862a6 --- /dev/null +++ b/docs-source/forms-source/form1-doc/variables/assignment.md @@ -0,0 +1,73 @@ + + +Now that you have a variable you will assign it a value different then what it was initialized with. + +#### It should assign the sum of 3 and 7 (3 + 7) to "a" + +Now assign variable `a` with the value of `3 + 7`. + +
Hints + +Add two numbers using the plus (+) operator + +
Code + +**Example 1** + +```javascript + let a = 5; + a = ? + ?; + + return { + }; +``` + +**Example 2** + +```javascript + var a = 5; + a = ? + ?; + + return { + }; +``` + +
+ +
+ +#### It should have a variable "b" initialized to "Hello, World!" + +Create a variable called `b` and initialize it with the value `"Hello, World!" + +
Hints + +Initialize a variable with equals: `var b = ...` + +
Code + +**Example 1** + +```javascript + let b = ?; + + return { + }; +``` + +**Example 2** + +```javascript + var b = ?; + + return { + }; +``` + +
+ +
\ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/variables/declaration.md b/docs-source/forms-source/form1-doc/variables/declaration.md new file mode 100644 index 0000000..7a6d90b --- /dev/null +++ b/docs-source/forms-source/form1-doc/variables/declaration.md @@ -0,0 +1,83 @@ + + +Here you will declare and initialize variables. + +#### It should have a variable called "a" + +Create a variable at the top of the block called "a". You will need to use `let` or `var`. + +
Hints + +Be sure you use "var" or "let" to declare your variable + +
Code + +**Example 1** + +```javascript +const jsforms = (function () { + 'use strict'; + let ?; + + return { + }; +})(); +``` + +**Example 2** + +```javascript +const jsforms = (function () { + 'use strict'; + var ?; + + return { + }; +})(); +``` + +
+ +
+ +#### It should initialize "a" with the value 5 + +Set the initial value of a to 5. + +
Hints + +Initialize a variable with equals: `var a = ...` + +
Code + +**Example 1** + +```javascript +const jsforms = (function () { + 'use strict'; + let a = ?; + + return { + }; +})(); +``` + +**Example 2** + +```javascript +const jsforms = (function () { + 'use strict'; + var a = ?; + + return { + }; +})(); +``` + +
+ +
\ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/variables/exposingValues.md b/docs-source/forms-source/form1-doc/variables/exposingValues.md new file mode 100644 index 0000000..8b57314 --- /dev/null +++ b/docs-source/forms-source/form1-doc/variables/exposingValues.md @@ -0,0 +1,29 @@ + + +You well now expose values to the outside world. + +#### It should expose variable "b" to be read outside of the module + +Expose the variable `b` to the outside world, by adding it the the object being exported. + +
Hints + +Find `return {};` add a "b" -> `return {b};` + +
Code + +**Example** + +```javascript + return { + ?, + }; +``` + +
+ +
diff --git a/docs-source/forms-source/form1-doc/variables/methodCall.md b/docs-source/forms-source/form1-doc/variables/methodCall.md new file mode 100644 index 0000000..5651793 --- /dev/null +++ b/docs-source/forms-source/form1-doc/variables/methodCall.md @@ -0,0 +1,38 @@ + +You will make a call to a method on an object. + +#### It should log variable "b" to the console + +Use the `console.log` method to log the value contained in variable `b` to the console. + +
Hints + +Console.log might be just the ticket... + +
Code + +**Example 1** + +```javascript + console.log(?); + + return { + }; +``` + +**Example 2** + +```javascript + console.log(?); + + return { + }; +``` + +
+ +
diff --git a/docs-source/forms-source/form4-doc/app/_main.md b/docs-source/forms-source/form4-doc/app/_main.md index 884ff36..ab9028d 100644 --- a/docs-source/forms-source/form4-doc/app/_main.md +++ b/docs-source/forms-source/form4-doc/app/_main.md @@ -5,7 +5,6 @@ /bl--> The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. - You will use functions to work with arrays and loops. -### \*\*sum function\*\* +### Sum Function ### You are going to create a function called `sum` that adds numbers together. -#### It should take the sum of one number +#### It should take the sum of one number #### Create a `sum` function that accepts an array and returns 1. @@ -35,7 +35,7 @@ Create a function that returns a simple number instead of worrying about actuall -#### It should add two numbers +#### It should add two numbers #### Modify the `sum` function so that it adds the first two numbers in an array. @@ -65,7 +65,7 @@ Add logic to sum 1 or two numbers (An `if` structure might help here) -#### It should add multiple numbers +#### It should add multiple numbers #### Modify the `sum` function to add all numbers in an array. @@ -115,7 +115,7 @@ Add logic to sum an arbitrary length array of numbers (A for loop might help to -### \*\*squareAll function\*\* +### Square All Function ### Create a function that squares each number in an array. @@ -124,7 +124,7 @@ The steps you will take to building the `squareAll` function are: 1. Add a `squareAll` function that returns a constant value. 2. Chang the `squareAll` function to perform square computation on array value -#### It should square all numbers in a single-value array +#### It should square all numbers in a single-value array #### Create a function called `squareAll` that takes an array and returns the square of the first element. @@ -151,7 +151,7 @@ Create a function that only squares the first value of an array and returns that -#### It should square multiple numbers +#### It should square multiple numbers #### Modify the `squareAll` function so that it now squares each number in the array. diff --git a/docs-source/forms-source/form1-doc/combining.md b/docs-source/forms-source/form1-doc/combining.md index a490d29..e7953b9 100644 --- a/docs-source/forms-source/form1-doc/combining.md +++ b/docs-source/forms-source/form1-doc/combining.md @@ -5,7 +5,7 @@ /bl--> You will now take code you wrote and use it define more complex behaviors -### \*\*magnitude function\*\* +### Magnitude Function ### You will create a function called `magnitude` that will calculate the magnitude of all given numbers. @@ -37,7 +37,7 @@ or > > d = 3 -#### It returns the magnitude of a vector with only one number +#### It returns the magnitude of a vector with only one number #### Create a function called `magnitude` that returns the first item in an array that is given to it. @@ -63,7 +63,7 @@ Can you just return a value from the array? -#### It returns only positive numbers -- all magnitudes are positive +#### It returns only positive numbers -- all magnitudes are positive #### Modify the `magnitude` function that returns the positive value of the first item in an array that is given to it. @@ -96,7 +96,7 @@ Currently the magnitude of a vector is computed by: -#### It should return the magnitude of a vector with two values +#### It should return the magnitude of a vector with two values #### Modify the `magnitude` function so that it returns the magnitude of the first 2 items in an array given to it. @@ -134,7 +134,7 @@ Currently the magnitude of a vector is computed by: -#### It should return the magnitude of a vector with multiple values +#### It should return the magnitude of a vector with multiple values #### Modify the `magnitude` function so that it returns the magnitude of all the values in the array. @@ -166,4 +166,4 @@ The magnitude of a vector is computed by: - + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/complex.md b/docs-source/forms-source/form1-doc/complex.md index 4f66e6e..5334eea 100644 --- a/docs-source/forms-source/form1-doc/complex.md +++ b/docs-source/forms-source/form1-doc/complex.md @@ -3,13 +3,14 @@ (title "Combining Complex Functions") ) /bl--> + You will use previous functions chained to gether to give us new results. -### \*\*sumOfSquares function\*\* +### sumOfSquares function ### Create a function that takes an array of numbers, squares each number and then returns the sum of those squares. -#### It should square number in a 1-length array and return it +#### It should square number in a 1-length array and return it #### Create a function called `sumOfSquares` that takes an array and returns the square of the first element. @@ -38,7 +39,7 @@ Try to do the following: -#### It should take the sum of squares of multiple numbers +#### It should take the sum of squares of multiple numbers #### Modify the `sumOfSquares` function so that it squares all numbers in the array. @@ -62,4 +63,4 @@ Add logic to square all numbers and return the sum (squareAll and sum might be u - + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/copying-arrays.md b/docs-source/forms-source/form1-doc/copying-arrays.md index 4d6c0ed..1e9382f 100644 --- a/docs-source/forms-source/form1-doc/copying-arrays.md +++ b/docs-source/forms-source/form1-doc/copying-arrays.md @@ -4,15 +4,16 @@ (subtitle "Using Array.slice") ) /bl--> + You are going to use functions to explore the `Array.prototype.slice` method. -### \*\*buildVector function\*\* +### buildVector function ### You will now create a function called `buildVector` that returns a copy of the array as it was passed. > A vector is an ordered set of points which describes a "directed line segment," in other words, a vector is a line segment with an arrow -#### It returns a vector (array) containing the same numbers as the original -- try returning the array you get in your function +#### It returns a vector (array) containing the same numbers as the original -- try returning the array you get in your function #### Create a function called `buildVector` that returns the same array passed to it. @@ -38,7 +39,7 @@ Add buildVector function (Would it be possible to just return something?) -#### It returns a copy of the original vector +#### It returns a copy of the original vector #### Modify the `buildVector` function so that it returns a copy of the array passed to it. (note: use the `slice` method on array.) @@ -63,4 +64,4 @@ Add logic to return a copy of vector array (Slice will create a new array just l - + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/functions.md b/docs-source/forms-source/form1-doc/functions.md index 2584b3a..0296b3f 100644 --- a/docs-source/forms-source/form1-doc/functions.md +++ b/docs-source/forms-source/form1-doc/functions.md @@ -4,11 +4,12 @@ (subtitle "[function declaration, return statement]") ) /bl--> + Time to create functions and have them return a value. -### \*\*greeter function\*\* +### greeter function ### -##### It should say "Hello!" by default +##### It should say "Hello!" by default ##### Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") @@ -34,9 +35,9 @@ Functions start with the keyword `function` followed by the name of the function -#### conditional logic [if/else] +#### conditional logic [if/else] #### -##### It should say "Salutations!" when Salutations is passed +##### It should say "Salutations!" when Salutations is passed ##### Modify the greet function to take a greeting and return the greeting if it was passed. @@ -67,13 +68,13 @@ Add condition to greet to handle custom greeting case. -### function calls and mathematical operations [Math library] +### function calls and mathematical operations [Math library] ### -#### \*\*square function\*\* +#### square function #### Create a function that takes a number and returns its square. -##### It should square 1 +##### It should square 1 ##### The function called `square` will be passed 1 and should return 1. @@ -99,7 +100,7 @@ Add square function that returns a simple value rather then worrying about actua -##### It should square 3 +##### It should square 3 ##### Modify the `square` function such that it returns the square of the value passed in. @@ -139,11 +140,11 @@ Modify the `square` function such that it returns the square of the value passed -#### \*\*squareRoot function\*\* +#### squareRoot function #### Create a function that takes a number and returns the square root of that number. (note: use the Math library). -##### It should take the square root of 1 +##### It should take the square root of 1 ##### Create a function called `squareRoot` that will be passed 1 and return 1. @@ -169,7 +170,7 @@ Create a function that returns a simple value rather then worrying about actuall -##### It should take the square root of 4 +##### It should take the square root of 4 ##### Modify the `squareRoot` function to return the square root of the value passed. diff --git a/docs-source/forms-source/form1-doc/looping.md b/docs-source/forms-source/form1-doc/looping.md index f2bf7b1..7bdbcb9 100644 --- a/docs-source/forms-source/form1-doc/looping.md +++ b/docs-source/forms-source/form1-doc/looping.md @@ -5,7 +5,7 @@ /bl--> Now it is time to use functions to examine looping and comparisons. -### \*\*getVectorsShorterThan\*\* +### getVectorsShorterThan ### You will now create a function called `getVectorsShorterThan` that will take an array of arrays. It will compare each array based on its magnitude and return all arrays that have a magnitude smaller then the number provided. @@ -17,7 +17,7 @@ getVectorsShorterThan(length, arrayOfVectors) Such that `length` is the number for which You will compare magnitudes against, and `arrayOfVectors` is the array of arrays, where then inner arrays are to contain numbers. -#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors +#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors #### Create a the function `getVectorsShorterThan` where the first parameter is `length` and the second parameter is `arrayOfVectors` that returns all vectors where the magnitude is less then 5. There is only one vector at this point and its length is less then 5. @@ -43,7 +43,7 @@ Can you just return the first value of the array? -#### It returns an empty array when all vectors are too long -- tests one vector +#### It returns an empty array when all vectors are too long -- tests one vector #### Modify the `getVectorsShorterThan` function so that it will return an empty array if the first vector has a magnitude longer then `length`. @@ -93,7 +93,7 @@ Add logic to handle the case where a vector is too long (How might you compare t -#### It returns an array of more than one vector when all are short enough +#### It returns an array of more than one vector when all are short enough #### Modify the `getVectorsShorterThan` function so that it returns all vectors if the first one has a magnitude less then the length. @@ -143,7 +143,7 @@ Add logic to handle 0, 1 or 2 vector cases -### It returns only vectors which are not too long +### It returns only vectors which are not too long #### Modify the `getVectorsShorterThan` function so that it now returns only those vectors with a magnitude less then the length. From 3b3d6da67196f08761c7a6291912383b65a5c8b8 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 07:53:50 -0800 Subject: [PATCH 49/63] docs: standardized headings --- .../form1-doc/variables/assignment.md | 4 +- .../form1-doc/variables/declaration.md | 4 +- .../form1-doc/variables/exposingValues.md | 2 +- .../form1-doc/variables/methodCall.md | 2 +- .../forms-source/form2-doc/buildVector.md | 18 ++-- .../form2-doc/getVectorsShorterThan.md | 10 +-- docs-source/forms-source/form2-doc/greeter.md | 8 +- .../forms-source/form2-doc/squareAll.md | 8 +- docs-source/forms-source/form2-doc/sum.md | 10 +-- .../forms-source/form3-doc/buildVector.md | 26 +++--- docs-source/forms-source/form3-doc/greeter.md | 10 +-- docs-source/forms-source/form3-doc/sum.md | 8 +- .../pointOfSaleDataUtilityFactoryBuilder.md | 4 +- docs/FIRST-FORM.md | 86 +++++++++---------- docs/SECOND-FORM.md | 54 ++++++------ docs/TEST-DUMMY-FORM.md | 5 +- docs/THIRD-FORM.md | 44 +++++----- 17 files changed, 151 insertions(+), 152 deletions(-) diff --git a/docs-source/forms-source/form1-doc/variables/assignment.md b/docs-source/forms-source/form1-doc/variables/assignment.md index a2862a6..e513d54 100644 --- a/docs-source/forms-source/form1-doc/variables/assignment.md +++ b/docs-source/forms-source/form1-doc/variables/assignment.md @@ -6,7 +6,7 @@ Now that you have a variable you will assign it a value different then what it was initialized with. -#### It should assign the sum of 3 and 7 (3 + 7) to "a" +#### It should assign the sum of 3 and 7 (3 + 7) to "a" #### Now assign variable `a` with the value of `3 + 7`. @@ -40,7 +40,7 @@ Add two numbers using the plus (+) operator -#### It should have a variable "b" initialized to "Hello, World!" +#### It should have a variable "b" initialized to "Hello, World!" #### Create a variable called `b` and initialize it with the value `"Hello, World!" diff --git a/docs-source/forms-source/form1-doc/variables/declaration.md b/docs-source/forms-source/form1-doc/variables/declaration.md index 7a6d90b..7379f13 100644 --- a/docs-source/forms-source/form1-doc/variables/declaration.md +++ b/docs-source/forms-source/form1-doc/variables/declaration.md @@ -6,7 +6,7 @@ Here you will declare and initialize variables. -#### It should have a variable called "a" +#### It should have a variable called "a" #### Create a variable at the top of the block called "a". You will need to use `let` or `var`. @@ -44,7 +44,7 @@ const jsforms = (function () { -#### It should initialize "a" with the value 5 +#### It should initialize "a" with the value 5 #### Set the initial value of a to 5. diff --git a/docs-source/forms-source/form1-doc/variables/exposingValues.md b/docs-source/forms-source/form1-doc/variables/exposingValues.md index 8b57314..69734c6 100644 --- a/docs-source/forms-source/form1-doc/variables/exposingValues.md +++ b/docs-source/forms-source/form1-doc/variables/exposingValues.md @@ -6,7 +6,7 @@ You well now expose values to the outside world. -#### It should expose variable "b" to be read outside of the module +#### It should expose variable "b" to be read outside of the module #### Expose the variable `b` to the outside world, by adding it the the object being exported. diff --git a/docs-source/forms-source/form1-doc/variables/methodCall.md b/docs-source/forms-source/form1-doc/variables/methodCall.md index 5651793..cfe4c7a 100644 --- a/docs-source/forms-source/form1-doc/variables/methodCall.md +++ b/docs-source/forms-source/form1-doc/variables/methodCall.md @@ -5,7 +5,7 @@ /bl--> You will make a call to a method on an object. -#### It should log variable "b" to the console +#### It should log variable "b" to the console #### Use the `console.log` method to log the value contained in variable `b` to the console. diff --git a/docs-source/forms-source/form2-doc/buildVector.md b/docs-source/forms-source/form2-doc/buildVector.md index 3ca7eb4..8bec670 100644 --- a/docs-source/forms-source/form2-doc/buildVector.md +++ b/docs-source/forms-source/form2-doc/buildVector.md @@ -5,11 +5,11 @@ /bl--> Now you will refactor the `buildVector` function changing its shape. -### Refactoring steps +### Refactoring steps ### These are the steps you will use to change the shape of the `buildVector` function without changing its behavior. -#### It has a refactoring in magnitude function to replace vector value with `vector.valueOf()` +#### It has a refactoring in magnitude function to replace vector value with `vector.valueOf()` #### Now modify the `magnitude` function by not passing the vector directly but passing the result of the `valueOf` method on vector. Currently the `valueOf` function just returns the original array. However this will make space for later changes that will happen to the `buildVector` function. @@ -32,7 +32,7 @@ Just add a `.valueOf()` call after the vector in the call to `sumOfSquares`. -#### It contains a constructor for an object called Vector +#### It contains a constructor for an object called Vector #### Now you will create a constructor for an object called `Vector`. You are not yet exporting that constructor. This constructor can just be an empty function. @@ -53,7 +53,7 @@ You will not be using JavaScripts class objects. Instead work from the original -#### It accepts a parameter "points" into Vector constructor +#### It accepts a parameter "points" into Vector constructor #### Modify the `Vector` function to take a parameter called points. There is no need to do anything with this parameter yet. @@ -74,7 +74,7 @@ The `Vector` constructor is just a function. All functions can have a name repre -#### It assigns `points` variable to "this.points" in `Vector` constructor +#### It assigns `points` variable to "this.points" in `Vector` constructor #### Modify the `Vector` constructor to save the `points` parameter. @@ -96,7 +96,7 @@ Remember in JavaScript, you do not have to predefine member variables before you -#### It overrides the valueOf function on the Vector prototype +#### It overrides the valueOf function on the Vector prototype #### Now you will need to override the internal `valueOf` function on `Vector`. Remember that `valueOf` comes from object and by default just returns the object. You will now change the behavior of this function to return a copy of its internal points. @@ -118,7 +118,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It overrides the `toString` function on the `Vector` prototype +#### It overrides the `toString` function on the `Vector` prototype #### Now you will need to override the internal `toString` function on `Vector`. Remember what you learned above. @@ -139,7 +139,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It should return a vector where toString returns a vector string +#### It should return a vector where toString returns a vector string #### You will modify the overridden `toString` method on `Vector` such that: @@ -187,7 +187,7 @@ You can use the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/ -#### It returns a new Vector object instead of an array +#### It returns a new Vector object instead of an array #### You will now modify the `buildVector` function to return a new `Vector` instead of an array of values. diff --git a/docs-source/forms-source/form2-doc/getVectorsShorterThan.md b/docs-source/forms-source/form2-doc/getVectorsShorterThan.md index 6c25fd0..6b71230 100644 --- a/docs-source/forms-source/form2-doc/getVectorsShorterThan.md +++ b/docs-source/forms-source/form2-doc/getVectorsShorterThan.md @@ -6,7 +6,7 @@ You will now modify the `getVectorsShorterThan` function changing its shape without changing its behavior. -### Refactoring steps +### Refactoring steps ### This is how you will modify the `getVectorsShorterThan` function such that it ensures you do not change its external behavior. @@ -16,7 +16,7 @@ This is how you will modify the `getVectorsShorterThan` function such that it en _**KEEP THE TESTS PASSING!**_ -#### It has a function called `isMagnitudeShorterThanLength` +#### It has a function called `isMagnitudeShorterThanLength` #### Create a function called `isMagnitudeShorterThanLength`. This can be an empty function right now. You are also _not_ exporting that function. @@ -37,7 +37,7 @@ Create a function that calculates the magnitude and then just return the value o -#### It has `vector` and `length` as parameters of `isMagnitudeShorterThanLength` +#### It has `vector` and `length` as parameters of `isMagnitudeShorterThanLength` #### You will modify the `isMagnitudeShorterThanLength` function to take the two parameters `vector` and `length`. You will also modify the function to return a [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) `true` if the vector's magnitude is less then the provided length and false if it is equal to or greater. @@ -60,7 +60,7 @@ You will need to calculate the magnitude (there is a function to help with this) -#### It is refactored to use `vectors.filter()` instead of for loop +#### It is refactored to use `vectors.filter()` instead of for loop #### You will modify the `getVectorsShorterThan` function to use the internal [`Array.prototype.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) instead of recreating the functionality in a for loop. @@ -84,7 +84,7 @@ The filter method takes a function as a parameter that returns a Boolean. If th -#### It does not assign filter to results, it just returns directly +#### It does not assign filter to results, it just returns directly #### Now modify the `getVectorsShorterThan` not to use the unnecessary variable `result`. diff --git a/docs-source/forms-source/form2-doc/greeter.md b/docs-source/forms-source/form2-doc/greeter.md index 17a5775..23fa177 100644 --- a/docs-source/forms-source/form2-doc/greeter.md +++ b/docs-source/forms-source/form2-doc/greeter.md @@ -5,11 +5,11 @@ /bl--> Let us change the `greet` function. -### Refactoring steps +### Refactoring steps ### Lets look at the steps in refactoring the `greet` function. -#### It is refactored to remove the unnecessary else +#### It is refactored to remove the unnecessary else #### Modify the `greet` function to remove the else statement. @@ -35,7 +35,7 @@ Because of the `return greeting + '!';` in the first part of the `if` statement -#### It is refactored to remove if and replace with a ternary expression +#### It is refactored to remove if and replace with a ternary expression #### Because both paths of the function return a value, you can change the shape of the code from an `if` `return` to a [ternary operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator). @@ -61,7 +61,7 @@ A ternary operator has the following form -#### It is refactored to use typeof comparison to "string" +#### It is refactored to use typeof comparison to "string" #### You will now modify the `greet` function to remove the `greeting === undefined` comparison and instead use the [typeof](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator to prove whether or not what was passed in was a string. diff --git a/docs-source/forms-source/form2-doc/squareAll.md b/docs-source/forms-source/form2-doc/squareAll.md index a8bb27c..9ce755c 100644 --- a/docs-source/forms-source/form2-doc/squareAll.md +++ b/docs-source/forms-source/form2-doc/squareAll.md @@ -5,11 +5,11 @@ /bl--> You will now refactor and change the shape of the `squareAll` method. -### Refactoring steps +### Refactoring steps ### These are the steps you will take in changing the shape of the `squareAll` method, to ensure you do not change its behavior. -#### It is refactored to replace for loop with `nums.map` +#### It is refactored to replace for loop with `nums.map` #### The [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function allows you to perform a function on each member of an array and capture the result. Use this method instead of the given for loop. @@ -41,7 +41,7 @@ The `Array.prototype.map` allows you to transform all values in an array such th -#### It is refactored to remove function wrapping `square` +#### It is refactored to remove function wrapping `square` #### Now modify the `squareAll` function to simplify the function expression or the arrow function expression. @@ -64,7 +64,7 @@ If you were to log all items in an array to the console, you don't need a functi -#### It is refactored to return result of map operation without assigning output to result +#### It is refactored to return result of map operation without assigning output to result #### Now modify the `squareAll` function to remove the unnecessary `result` variable. diff --git a/docs-source/forms-source/form2-doc/sum.md b/docs-source/forms-source/form2-doc/sum.md index ae8e066..1c290d1 100644 --- a/docs-source/forms-source/form2-doc/sum.md +++ b/docs-source/forms-source/form2-doc/sum.md @@ -5,11 +5,11 @@ /bl--> You are going to refactor and change the shape of the `sum` method. -### Refactoring steps +### Refactoring steps ### These are the steps you will use to change the shape of the `sum` method, thereby changing how it does its work, while not changing the work it does. -#### It has an add function +#### It has an add function #### Now create a function called `add` that takes two number and adds them. You are _not_ exporting this function, it is part of your refactoring of the `sum` function. @@ -29,7 +29,7 @@ Return the values after using the `+` operator. -#### It is refactored to replace += with a call to the add function +#### It is refactored to replace += with a call to the add function #### Modify the `sum` method to use the new `add` method above instead of the `+=` operator. @@ -57,7 +57,7 @@ The `+=` operator is equivalent to setting a value to itself plus the other valu -#### It is refactored to replace for loop with `nums.forEach` +#### It is refactored to replace for loop with `nums.forEach` #### Now modify the `sum` method to remove the `for` loop, and use the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) method provided on nums. @@ -83,7 +83,7 @@ Now modify the `sum` method to remove the `for` loop, and use the [`Array.protot -#### It is refactored to replace the function expression with an arrow function +#### It is refactored to replace the function expression with an arrow function #### Now modify the `sum` function to replace the function expression with an [arrow function expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). diff --git a/docs-source/forms-source/form3-doc/buildVector.md b/docs-source/forms-source/form3-doc/buildVector.md index fbf4fe6..308267f 100644 --- a/docs-source/forms-source/form3-doc/buildVector.md +++ b/docs-source/forms-source/form3-doc/buildVector.md @@ -5,11 +5,11 @@ /bl--> You will refactor the `buildVector` function. -### Getter properties and value immutability +### Getter properties and value immutability ### You will learn how to add readonly properties to an object. You will be modifying the `Vector` object. -#### It should have access to read, but not write, vector.points +#### It should have access to read, but not write, vector.points #### The `Vector` object's internal `points` array should be read only. This is accomplished by using a [property getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get). @@ -39,7 +39,7 @@ function Vector(points) { -#### It should not change `Vector` object when the original array is modified +#### It should not change `Vector` object when the original array is modified #### Now you will modify the `Vector` function to return a copy of the array passed into it. This will isolate the `Vector` object from changes that happen outside of the object. @@ -64,7 +64,7 @@ Maybe the `Array.prototype.slice` method might be useful. -#### It should not be possible to modify `vector.points` +#### It should not be possible to modify `vector.points` #### Modify the `Vector` method to make the copy of the `points` array read only. @@ -89,11 +89,11 @@ It might help to use the [Object.freeze](https://developer.mozilla.org/en-US/doc -#### Constructor type check +#### Constructor type check #### You will be modifying the `Vector` function to have better type checking. This will include type validation and throwing of errors. -#### It throws an error if constructor is called with a value which is not an array +#### It throws an error if constructor is called with a value which is not an array #### Modify the `Vector` function to throw an error if the `points` parameter is not a type of an array. @@ -122,7 +122,7 @@ To test that something is an array or not, you cannot use the `typeOf` function -#### It throws an error if constructor is called with an array of one value which is not a number +#### It throws an error if constructor is called with an array of one value which is not a number #### Modify the `Vector` function to check the type of the first element in the array to ensure it is a number. Then `throw` a new `Error` if it isn't. @@ -155,7 +155,7 @@ You might be able to use the `isTypeOf` function here. -#### It throws an error if constructor is called with an array which contains values other than numbers +#### It throws an error if constructor is called with an array which contains values other than numbers #### Modify the `Vector` function to check the type of all elements in the array to ensure that they are all numbers. Then `throw` a new `Error` if any of them are not. @@ -210,14 +210,14 @@ You might be able to use the `Array.prototype.filter` method or the `Array.proto -#### Refactoring steps +#### Refactoring steps #### Now you will modify the `Vector` method such that you will change the shape of it without changing the behavior. 1. You will create methods that handle the type checking. 2. You will then utilize these methods instead of having the error checking embedded in the `Vector` constructor. -##### It has a function called `assertArray` with parameter `values` +##### It has a function called `assertArray` with parameter `values` ##### Create a function called `assertArray` which will look at the type of the parameter `values` and throw an exception if `values` is not an array. @@ -241,7 +241,7 @@ You already have the code, you will just add it into a new function. -##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' +##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' ##### Now create a function called `assertArrayOfType` that compares all items in `values` with the given `type` and throws an exception if any of the values are not the correct type. @@ -278,7 +278,7 @@ Again you already have this code. You just need to add it in the new function. -##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' +##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' ##### Modify the `assertArrayOfType` function to call the `assertArray` function before it checks the values in the array. @@ -312,7 +312,7 @@ Modify the `assertArrayOfType` function to call the `assertArray` function befor -##### It has a call in `Vector` constructor to `assertArrayOfType` +##### It has a call in `Vector` constructor to `assertArrayOfType` ##### Now modify the `Vector` function to call the `assertArrayOfType` instead of the logic to check the type. diff --git a/docs-source/forms-source/form3-doc/greeter.md b/docs-source/forms-source/form3-doc/greeter.md index 7c15f99..07e5142 100644 --- a/docs-source/forms-source/form3-doc/greeter.md +++ b/docs-source/forms-source/form3-doc/greeter.md @@ -5,7 +5,7 @@ /bl--> You are going to start by refactoring the `greet` function. -### Refactoring steps +### Refactoring steps ### Here are the steps you will take to refactor the `greet` function to ensure you change the shape without changing the behavior. @@ -14,7 +14,7 @@ Here are the steps you will take to refactor the `greet` function to ensure you 3. Create function called `eitherOnType` 4. Replace ternary in greet function with `eitherOnType` -#### It has a function called `isTypeOf` which takes parameters `type` and `value` +#### It has a function called `isTypeOf` which takes parameters `type` and `value` #### Create a function called `isTypeOf` with the two parameters of `type` and `value`. You are _not_ exporting this function. This function checks the type of the `value` and returns a Boolean true if the `value` is of the given `type`. @@ -36,7 +36,7 @@ This will use `typeOf` to do the check. -#### It calls isTypeOf from greet +#### It calls isTypeOf from greet #### Now you will modify the `greet` function to use the `isTypeOf` function instead of the `typeOf` function. @@ -58,7 +58,7 @@ You will need to replace not only the call to `typeOf` but also the comparison t -#### It has a function called `eitherOnType` with parameters `type`, `testValue`, `defaultValue` -- return `testValue` if it matches `type`, otherwise return `defaultValue` +#### It has a function called `eitherOnType` with parameters `type`, `testValue`, `defaultValue` -- return `testValue` if it matches `type`, otherwise return `defaultValue` #### Create a the function `eitherOnType`, you will _not_ export this function. The `eitherOnType` function takes two parameters `testValue` and `type`. It then compares the `testValue`'s type. If the `testValue` has the same type as the one given, it returns the `testValue`. If the `testValue` has a different type then it returns the `defaultValue`. @@ -92,7 +92,7 @@ You will want to use the new `isTypeOf` function. -#### It calls eitherOnType from greet +#### It calls eitherOnType from greet #### Modify the `greet` function so that you replace the trinary operator with the `eitherOnType` function. diff --git a/docs-source/forms-source/form3-doc/sum.md b/docs-source/forms-source/form3-doc/sum.md index 05c2077..6b6d69e 100644 --- a/docs-source/forms-source/form3-doc/sum.md +++ b/docs-source/forms-source/form3-doc/sum.md @@ -5,7 +5,7 @@ /bl--> You will refactor the `sum` function. -### Refactoring steps +### Refactoring steps ### Here are the steps you will take to refactor the `sum` method so that you can change its shape without changing its behavior. @@ -15,7 +15,7 @@ Here are the steps you will take to refactor the `sum` method so that you can ch _**KEEP THE TESTS PASSING!**_ -#### It has been refactored to use `reduce` in the place of `forEach`, assigning the output to result +#### It has been refactored to use `reduce` in the place of `forEach`, assigning the output to result #### Modify the `sum` function to use the [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) method in place of the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) method. @@ -52,7 +52,7 @@ In short you can use this similarly to the `forEach` method but without the need -#### It has been refactored to pass the add function directly to reduce +#### It has been refactored to pass the add function directly to reduce #### Modify the `sum` function to no longer use a function expression and instead just directly use the `add` function. @@ -76,7 +76,7 @@ The `reduce` method takes a function with two parameters, `add` takes two parame -#### It has been refactored to not assign the sum before returning it +#### It has been refactored to not assign the sum before returning it #### Modify the `sum` function to just return the result instead of assigning it to a variable. diff --git a/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md index d198f67..805ecd7 100644 --- a/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md +++ b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md @@ -20,7 +20,7 @@ These values are already set up for you. This function returns an object with two methods. -#### `getProductCountBySale` +#### `getProductCountBySale` #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -69,7 +69,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -#### `getProductCountByReturn` +#### `getProductCountByReturn` #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index f0f1b33..2a9388b 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -27,7 +27,7 @@ You will explore the creation and use of variables. Here you will declare and initialize variables. -#### It should have a variable called "a" +#### It should have a variable called "a" #### Create a variable at the top of the block called "a". You will need to use `let` or `var`. @@ -65,7 +65,7 @@ const jsforms = (function () { -#### It should initialize "a" with the value 5 +#### It should initialize "a" with the value 5 #### Set the initial value of a to 5. @@ -108,7 +108,7 @@ const jsforms = (function () { Now that you have a variable you will assign it a value different then what it was initialized with. -#### It should assign the sum of 3 and 7 (3 + 7) to "a" +#### It should assign the sum of 3 and 7 (3 + 7) to "a" #### Now assign variable `a` with the value of `3 + 7`. @@ -142,7 +142,7 @@ Add two numbers using the plus (+) operator -#### It should have a variable "b" initialized to "Hello, World!" +#### It should have a variable "b" initialized to "Hello, World!" #### Create a variable called `b` and initialize it with the value `"Hello, World!" @@ -178,7 +178,7 @@ Initialize a variable with equals: `var b = ...` ### Method Call ### You will make a call to a method on an object. -#### It should log variable "b" to the console +#### It should log variable "b" to the console #### Use the `console.log` method to log the value contained in variable `b` to the console. @@ -216,7 +216,7 @@ Console.log might be just the ticket... You well now expose values to the outside world. -#### It should expose variable "b" to be read outside of the module +#### It should expose variable "b" to be read outside of the module #### Expose the variable `b` to the outside world, by adding it the the object being exported. @@ -243,11 +243,12 @@ Find `return {};` add a "b" -> `return {b};` ## Function Creation ## #### [function declaration, return statement] #### + Time to create functions and have them return a value. -### \*\*greeter function\*\* +### greeter function ### -##### It should say "Hello!" by default +##### It should say "Hello!" by default ##### Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") @@ -273,9 +274,9 @@ Functions start with the keyword `function` followed by the name of the function -#### conditional logic [if/else] +#### conditional logic [if/else] #### -##### It should say "Salutations!" when Salutations is passed +##### It should say "Salutations!" when Salutations is passed ##### Modify the greet function to take a greeting and return the greeting if it was passed. @@ -306,13 +307,13 @@ Add condition to greet to handle custom greeting case. -### function calls and mathematical operations [Math library] +### function calls and mathematical operations [Math library] ### -#### \*\*square function\*\* +#### square function #### Create a function that takes a number and returns its square. -##### It should square 1 +##### It should square 1 ##### The function called `square` will be passed 1 and should return 1. @@ -338,7 +339,7 @@ Add square function that returns a simple value rather then worrying about actua -##### It should square 3 +##### It should square 3 ##### Modify the `square` function such that it returns the square of the value passed in. @@ -378,11 +379,11 @@ Modify the `square` function such that it returns the square of the value passed -#### \*\*squareRoot function\*\* +#### squareRoot function #### Create a function that takes a number and returns the square root of that number. (note: use the Math library). -##### It should take the square root of 1 +##### It should take the square root of 1 ##### Create a function called `squareRoot` that will be passed 1 and return 1. @@ -408,7 +409,7 @@ Create a function that returns a simple value rather then worrying about actuall -##### It should take the square root of 4 +##### It should take the square root of 4 ##### Modify the `squareRoot` function to return the square root of the value passed. @@ -439,11 +440,11 @@ Add logic to properly take square root ## Arrays, Loops, and Function Calls ## You will use functions to work with arrays and loops. -### \*\*sum function\*\* +### Sum Function ### You are going to create a function called `sum` that adds numbers together. -#### It should take the sum of one number +#### It should take the sum of one number #### Create a `sum` function that accepts an array and returns 1. @@ -469,7 +470,7 @@ Create a function that returns a simple number instead of worrying about actuall -#### It should add two numbers +#### It should add two numbers #### Modify the `sum` function so that it adds the first two numbers in an array. @@ -499,7 +500,7 @@ Add logic to sum 1 or two numbers (An `if` structure might help here) -#### It should add multiple numbers +#### It should add multiple numbers #### Modify the `sum` function to add all numbers in an array. @@ -549,7 +550,7 @@ Add logic to sum an arbitrary length array of numbers (A for loop might help to -### \*\*squareAll function\*\* +### Square All Function ### Create a function that squares each number in an array. @@ -558,7 +559,7 @@ The steps you will take to building the `squareAll` function are: 1. Add a `squareAll` function that returns a constant value. 2. Chang the `squareAll` function to perform square computation on array value -#### It should square all numbers in a single-value array +#### It should square all numbers in a single-value array #### Create a function called `squareAll` that takes an array and returns the square of the first element. @@ -585,7 +586,7 @@ Create a function that only squares the first value of an array and returns that -#### It should square multiple numbers +#### It should square multiple numbers #### Modify the `squareAll` function so that it now squares each number in the array. @@ -617,13 +618,14 @@ Add logic to square all numbers in array (How did you solve sum?) ## Combining Complex Functions ## + You will use previous functions chained to gether to give us new results. -### \*\*sumOfSquares function\*\* +### sumOfSquares function ### Create a function that takes an array of numbers, squares each number and then returns the sum of those squares. -#### It should square number in a 1-length array and return it +#### It should square number in a 1-length array and return it #### Create a function called `sumOfSquares` that takes an array and returns the square of the first element. @@ -652,7 +654,7 @@ Try to do the following: -#### It should take the sum of squares of multiple numbers +#### It should take the sum of squares of multiple numbers #### Modify the `sumOfSquares` function so that it squares all numbers in the array. @@ -677,20 +679,20 @@ Add logic to square all numbers and return the sum (squareAll and sum might be u - ## Copying Arrays ## #### Using Array.slice #### + You are going to use functions to explore the `Array.prototype.slice` method. -### \*\*buildVector function\*\* +### buildVector function ### You will now create a function called `buildVector` that returns a copy of the array as it was passed. > A vector is an ordered set of points which describes a "directed line segment," in other words, a vector is a line segment with an arrow -#### It returns a vector (array) containing the same numbers as the original -- try returning the array you get in your function +#### It returns a vector (array) containing the same numbers as the original -- try returning the array you get in your function #### Create a function called `buildVector` that returns the same array passed to it. @@ -716,7 +718,7 @@ Add buildVector function (Would it be possible to just return something?) -#### It returns a copy of the original vector +#### It returns a copy of the original vector #### Modify the `buildVector` function so that it returns a copy of the array passed to it. (note: use the `slice` method on array.) @@ -742,13 +744,12 @@ Add logic to return a copy of vector array (Slice will create a new array just l - ## Combining existing code to solve new problems ## You will now take code you wrote and use it define more complex behaviors -### \*\*magnitude function\*\* +### Magnitude Function ### You will create a function called `magnitude` that will calculate the magnitude of all given numbers. @@ -780,7 +781,7 @@ or > > d = 3 -#### It returns the magnitude of a vector with only one number +#### It returns the magnitude of a vector with only one number #### Create a function called `magnitude` that returns the first item in an array that is given to it. @@ -806,7 +807,7 @@ Can you just return a value from the array? -#### It returns only positive numbers -- all magnitudes are positive +#### It returns only positive numbers -- all magnitudes are positive #### Modify the `magnitude` function that returns the positive value of the first item in an array that is given to it. @@ -839,7 +840,7 @@ Currently the magnitude of a vector is computed by: -#### It should return the magnitude of a vector with two values +#### It should return the magnitude of a vector with two values #### Modify the `magnitude` function so that it returns the magnitude of the first 2 items in an array given to it. @@ -877,7 +878,7 @@ Currently the magnitude of a vector is computed by: -#### It should return the magnitude of a vector with multiple values +#### It should return the magnitude of a vector with multiple values #### Modify the `magnitude` function so that it returns the magnitude of all the values in the array. @@ -910,13 +911,12 @@ The magnitude of a vector is computed by: - ## Looping and inequality comparison ## Now it is time to use functions to examine looping and comparisons. -### \*\*getVectorsShorterThan\*\* +### getVectorsShorterThan ### You will now create a function called `getVectorsShorterThan` that will take an array of arrays. It will compare each array based on its magnitude and return all arrays that have a magnitude smaller then the number provided. @@ -928,7 +928,7 @@ getVectorsShorterThan(length, arrayOfVectors) Such that `length` is the number for which You will compare magnitudes against, and `arrayOfVectors` is the array of arrays, where then inner arrays are to contain numbers. -#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors +#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors #### Create a the function `getVectorsShorterThan` where the first parameter is `length` and the second parameter is `arrayOfVectors` that returns all vectors where the magnitude is less then 5. There is only one vector at this point and its length is less then 5. @@ -954,7 +954,7 @@ Can you just return the first value of the array? -#### It returns an empty array when all vectors are too long -- tests one vector +#### It returns an empty array when all vectors are too long -- tests one vector #### Modify the `getVectorsShorterThan` function so that it will return an empty array if the first vector has a magnitude longer then `length`. @@ -1004,7 +1004,7 @@ Add logic to handle the case where a vector is too long (How might you compare t -#### It returns an array of more than one vector when all are short enough +#### It returns an array of more than one vector when all are short enough #### Modify the `getVectorsShorterThan` function so that it returns all vectors if the first one has a magnitude less then the length. @@ -1054,7 +1054,7 @@ Add logic to handle 0, 1 or 2 vector cases -### It returns only vectors which are not too long +### It returns only vectors which are not too long #### Modify the `getVectorsShorterThan` function so that it now returns only those vectors with a magnitude less then the length. diff --git a/docs/SECOND-FORM.md b/docs/SECOND-FORM.md index 9675b41..d814d8a 100644 --- a/docs/SECOND-FORM.md +++ b/docs/SECOND-FORM.md @@ -22,11 +22,11 @@ You will be working in the [jsforms-source/2_second-form.js](../jsforms-source/2 ## Greeter ## Let us change the `greet` function. -### Refactoring steps +### Refactoring steps ### Lets look at the steps in refactoring the `greet` function. -#### It is refactored to remove the unnecessary else +#### It is refactored to remove the unnecessary else #### Modify the `greet` function to remove the else statement. @@ -52,7 +52,7 @@ Because of the `return greeting + '!';` in the first part of the `if` statement -#### It is refactored to remove if and replace with a ternary expression +#### It is refactored to remove if and replace with a ternary expression #### Because both paths of the function return a value, you can change the shape of the code from an `if` `return` to a [ternary operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator). @@ -78,7 +78,7 @@ A ternary operator has the following form -#### It is refactored to use typeof comparison to "string" +#### It is refactored to use typeof comparison to "string" #### You will now modify the `greet` function to remove the `greeting === undefined` comparison and instead use the [typeof](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator to prove whether or not what was passed in was a string. @@ -105,11 +105,11 @@ The `typeof` operator returns a string with the name of the type. Maybe you can ## Sum ## You are going to refactor and change the shape of the `sum` method. -### Refactoring steps +### Refactoring steps ### These are the steps you will use to change the shape of the `sum` method, thereby changing how it does its work, while not changing the work it does. -#### It has an add function +#### It has an add function #### Now create a function called `add` that takes two number and adds them. You are _not_ exporting this function, it is part of your refactoring of the `sum` function. @@ -129,7 +129,7 @@ Return the values after using the `+` operator. -#### It is refactored to replace += with a call to the add function +#### It is refactored to replace += with a call to the add function #### Modify the `sum` method to use the new `add` method above instead of the `+=` operator. @@ -157,7 +157,7 @@ The `+=` operator is equivalent to setting a value to itself plus the other valu -#### It is refactored to replace for loop with `nums.forEach` +#### It is refactored to replace for loop with `nums.forEach` #### Now modify the `sum` method to remove the `for` loop, and use the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) method provided on nums. @@ -183,7 +183,7 @@ Now modify the `sum` method to remove the `for` loop, and use the [`Array.protot -#### It is refactored to replace the function expression with an arrow function +#### It is refactored to replace the function expression with an arrow function #### Now modify the `sum` function to replace the function expression with an [arrow function expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). @@ -211,11 +211,11 @@ An arrow function expression to log a value to the console looks like `value => ## Square All ## You will now refactor and change the shape of the `squareAll` method. -### Refactoring steps +### Refactoring steps ### These are the steps you will take in changing the shape of the `squareAll` method, to ensure you do not change its behavior. -#### It is refactored to replace for loop with `nums.map` +#### It is refactored to replace for loop with `nums.map` #### The [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function allows you to perform a function on each member of an array and capture the result. Use this method instead of the given for loop. @@ -247,7 +247,7 @@ The `Array.prototype.map` allows you to transform all values in an array such th -#### It is refactored to remove function wrapping `square` +#### It is refactored to remove function wrapping `square` #### Now modify the `squareAll` function to simplify the function expression or the arrow function expression. @@ -270,7 +270,7 @@ If you were to log all items in an array to the console, you don't need a functi -#### It is refactored to return result of map operation without assigning output to result +#### It is refactored to return result of map operation without assigning output to result #### Now modify the `squareAll` function to remove the unnecessary `result` variable. @@ -294,11 +294,11 @@ Instead of an assignment, maybe just return the result of map. ## Build Vector ## Now you will refactor the `buildVector` function changing its shape. -### Refactoring steps +### Refactoring steps ### These are the steps you will use to change the shape of the `buildVector` function without changing its behavior. -#### It has a refactoring in magnitude function to replace vector value with `vector.valueOf()` +#### It has a refactoring in magnitude function to replace vector value with `vector.valueOf()` #### Now modify the `magnitude` function by not passing the vector directly but passing the result of the `valueOf` method on vector. Currently the `valueOf` function just returns the original array. However this will make space for later changes that will happen to the `buildVector` function. @@ -321,7 +321,7 @@ Just add a `.valueOf()` call after the vector in the call to `sumOfSquares`. -#### It contains a constructor for an object called Vector +#### It contains a constructor for an object called Vector #### Now you will create a constructor for an object called `Vector`. You are not yet exporting that constructor. This constructor can just be an empty function. @@ -342,7 +342,7 @@ You will not be using JavaScripts class objects. Instead work from the original -#### It accepts a parameter "points" into Vector constructor +#### It accepts a parameter "points" into Vector constructor #### Modify the `Vector` function to take a parameter called points. There is no need to do anything with this parameter yet. @@ -363,7 +363,7 @@ The `Vector` constructor is just a function. All functions can have a name repre -#### It assigns `points` variable to "this.points" in `Vector` constructor +#### It assigns `points` variable to "this.points" in `Vector` constructor #### Modify the `Vector` constructor to save the `points` parameter. @@ -385,7 +385,7 @@ Remember in JavaScript, you do not have to predefine member variables before you -#### It overrides the valueOf function on the Vector prototype +#### It overrides the valueOf function on the Vector prototype #### Now you will need to override the internal `valueOf` function on `Vector`. Remember that `valueOf` comes from object and by default just returns the object. You will now change the behavior of this function to return a copy of its internal points. @@ -407,7 +407,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It overrides the `toString` function on the `Vector` prototype +#### It overrides the `toString` function on the `Vector` prototype #### Now you will need to override the internal `toString` function on `Vector`. Remember what you learned above. @@ -428,7 +428,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It should return a vector where toString returns a vector string +#### It should return a vector where toString returns a vector string #### You will modify the overridden `toString` method on `Vector` such that: @@ -476,7 +476,7 @@ You can use the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/ -#### It returns a new Vector object instead of an array +#### It returns a new Vector object instead of an array #### You will now modify the `buildVector` function to return a new `Vector` instead of an array of values. @@ -503,7 +503,7 @@ Remember to use the `new` keyword in your return value. You will now modify the `getVectorsShorterThan` function changing its shape without changing its behavior. -### Refactoring steps +### Refactoring steps ### This is how you will modify the `getVectorsShorterThan` function such that it ensures you do not change its external behavior. @@ -513,7 +513,7 @@ This is how you will modify the `getVectorsShorterThan` function such that it en _**KEEP THE TESTS PASSING!**_ -#### It has a function called `isMagnitudeShorterThanLength` +#### It has a function called `isMagnitudeShorterThanLength` #### Create a function called `isMagnitudeShorterThanLength`. This can be an empty function right now. You are also _not_ exporting that function. @@ -534,7 +534,7 @@ Create a function that calculates the magnitude and then just return the value o -#### It has `vector` and `length` as parameters of `isMagnitudeShorterThanLength` +#### It has `vector` and `length` as parameters of `isMagnitudeShorterThanLength` #### You will modify the `isMagnitudeShorterThanLength` function to take the two parameters `vector` and `length`. You will also modify the function to return a [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) `true` if the vector's magnitude is less then the provided length and false if it is equal to or greater. @@ -557,7 +557,7 @@ You will need to calculate the magnitude (there is a function to help with this) -#### It is refactored to use `vectors.filter()` instead of for loop +#### It is refactored to use `vectors.filter()` instead of for loop #### You will modify the `getVectorsShorterThan` function to use the internal [`Array.prototype.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) instead of recreating the functionality in a for loop. @@ -581,7 +581,7 @@ The filter method takes a function as a parameter that returns a Boolean. If th -#### It does not assign filter to results, it just returns directly +#### It does not assign filter to results, it just returns directly #### Now modify the `getVectorsShorterThan` not to use the unnecessary variable `result`. diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index 04437ea..dc7e44f 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -43,7 +43,6 @@ This section is doable without the hints. it is _hard_ but doable. However, the The application under test is a Point of Sale reporting utility. It will report on all sales or all returns. - ### Sales Report App — Important Files ### > jsforms-source/4_test-dummy-form/sales-reporter/[salesReporterFactory.js](../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js) @@ -68,7 +67,7 @@ These values are already set up for you. This function returns an object with two methods. -#### `getProductCountBySale` +#### `getProductCountBySale` #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -117,7 +116,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -#### `getProductCountByReturn` +#### `getProductCountByReturn` #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: diff --git a/docs/THIRD-FORM.md b/docs/THIRD-FORM.md index c8ea6a8..2e30fa9 100644 --- a/docs/THIRD-FORM.md +++ b/docs/THIRD-FORM.md @@ -20,7 +20,7 @@ You will be working in the [jsforms-source/3_third-form.js](../jsforms-source/3_ ## Greeter ## You are going to start by refactoring the `greet` function. -### Refactoring steps +### Refactoring steps ### Here are the steps you will take to refactor the `greet` function to ensure you change the shape without changing the behavior. @@ -29,7 +29,7 @@ Here are the steps you will take to refactor the `greet` function to ensure you 3. Create function called `eitherOnType` 4. Replace ternary in greet function with `eitherOnType` -#### It has a function called `isTypeOf` which takes parameters `type` and `value` +#### It has a function called `isTypeOf` which takes parameters `type` and `value` #### Create a function called `isTypeOf` with the two parameters of `type` and `value`. You are _not_ exporting this function. This function checks the type of the `value` and returns a Boolean true if the `value` is of the given `type`. @@ -51,7 +51,7 @@ This will use `typeOf` to do the check. -#### It calls isTypeOf from greet +#### It calls isTypeOf from greet #### Now you will modify the `greet` function to use the `isTypeOf` function instead of the `typeOf` function. @@ -73,7 +73,7 @@ You will need to replace not only the call to `typeOf` but also the comparison t -#### It has a function called `eitherOnType` with parameters `type`, `testValue`, `defaultValue` -- return `testValue` if it matches `type`, otherwise return `defaultValue` +#### It has a function called `eitherOnType` with parameters `type`, `testValue`, `defaultValue` -- return `testValue` if it matches `type`, otherwise return `defaultValue` #### Create a the function `eitherOnType`, you will _not_ export this function. The `eitherOnType` function takes two parameters `testValue` and `type`. It then compares the `testValue`'s type. If the `testValue` has the same type as the one given, it returns the `testValue`. If the `testValue` has a different type then it returns the `defaultValue`. @@ -107,7 +107,7 @@ You will want to use the new `isTypeOf` function. -#### It calls eitherOnType from greet +#### It calls eitherOnType from greet #### Modify the `greet` function so that you replace the trinary operator with the `eitherOnType` function. @@ -133,7 +133,7 @@ The trinary operator has effectively moved to the `eitherOnType` method. The one ## Sum ## You will refactor the `sum` function. -### Refactoring steps +### Refactoring steps ### Here are the steps you will take to refactor the `sum` method so that you can change its shape without changing its behavior. @@ -143,7 +143,7 @@ Here are the steps you will take to refactor the `sum` method so that you can ch _**KEEP THE TESTS PASSING!**_ -#### It has been refactored to use `reduce` in the place of `forEach`, assigning the output to result +#### It has been refactored to use `reduce` in the place of `forEach`, assigning the output to result #### Modify the `sum` function to use the [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) method in place of the [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) method. @@ -180,7 +180,7 @@ In short you can use this similarly to the `forEach` method but without the need -#### It has been refactored to pass the add function directly to reduce +#### It has been refactored to pass the add function directly to reduce #### Modify the `sum` function to no longer use a function expression and instead just directly use the `add` function. @@ -204,7 +204,7 @@ The `reduce` method takes a function with two parameters, `add` takes two parame -#### It has been refactored to not assign the sum before returning it +#### It has been refactored to not assign the sum before returning it #### Modify the `sum` function to just return the result instead of assigning it to a variable. @@ -230,11 +230,11 @@ Get rid of the `result` variable and just return the result of the call to reduc ## Build Vector ## You will refactor the `buildVector` function. -### Getter properties and value immutability +### Getter properties and value immutability ### You will learn how to add readonly properties to an object. You will be modifying the `Vector` object. -#### It should have access to read, but not write, vector.points +#### It should have access to read, but not write, vector.points #### The `Vector` object's internal `points` array should be read only. This is accomplished by using a [property getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get). @@ -264,7 +264,7 @@ function Vector(points) { -#### It should not change `Vector` object when the original array is modified +#### It should not change `Vector` object when the original array is modified #### Now you will modify the `Vector` function to return a copy of the array passed into it. This will isolate the `Vector` object from changes that happen outside of the object. @@ -289,7 +289,7 @@ Maybe the `Array.prototype.slice` method might be useful. -#### It should not be possible to modify `vector.points` +#### It should not be possible to modify `vector.points` #### Modify the `Vector` method to make the copy of the `points` array read only. @@ -314,11 +314,11 @@ It might help to use the [Object.freeze](https://developer.mozilla.org/en-US/doc -#### Constructor type check +#### Constructor type check #### You will be modifying the `Vector` function to have better type checking. This will include type validation and throwing of errors. -#### It throws an error if constructor is called with a value which is not an array +#### It throws an error if constructor is called with a value which is not an array #### Modify the `Vector` function to throw an error if the `points` parameter is not a type of an array. @@ -347,7 +347,7 @@ To test that something is an array or not, you cannot use the `typeOf` function -#### It throws an error if constructor is called with an array of one value which is not a number +#### It throws an error if constructor is called with an array of one value which is not a number #### Modify the `Vector` function to check the type of the first element in the array to ensure it is a number. Then `throw` a new `Error` if it isn't. @@ -380,7 +380,7 @@ You might be able to use the `isTypeOf` function here. -#### It throws an error if constructor is called with an array which contains values other than numbers +#### It throws an error if constructor is called with an array which contains values other than numbers #### Modify the `Vector` function to check the type of all elements in the array to ensure that they are all numbers. Then `throw` a new `Error` if any of them are not. @@ -435,14 +435,14 @@ You might be able to use the `Array.prototype.filter` method or the `Array.proto -#### Refactoring steps +#### Refactoring steps #### Now you will modify the `Vector` method such that you will change the shape of it without changing the behavior. 1. You will create methods that handle the type checking. 2. You will then utilize these methods instead of having the error checking embedded in the `Vector` constructor. -##### It has a function called `assertArray` with parameter `values` +##### It has a function called `assertArray` with parameter `values` ##### Create a function called `assertArray` which will look at the type of the parameter `values` and throw an exception if `values` is not an array. @@ -466,7 +466,7 @@ You already have the code, you will just add it into a new function. -##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' +##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' ##### Now create a function called `assertArrayOfType` that compares all items in `values` with the given `type` and throws an exception if any of the values are not the correct type. @@ -503,7 +503,7 @@ Again you already have this code. You just need to add it in the new function. -##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' +##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' ##### Modify the `assertArrayOfType` function to call the `assertArray` function before it checks the values in the array. @@ -537,7 +537,7 @@ Modify the `assertArrayOfType` function to call the `assertArray` function befor -##### It has a call in `Vector` constructor to `assertArrayOfType` +##### It has a call in `Vector` constructor to `assertArrayOfType` ##### Now modify the `Vector` function to call the `assertArrayOfType` instead of the logic to check the type. From 76f1ec923210f5bdc557aa92fbb4f2afd46868c9 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 07:57:08 -0800 Subject: [PATCH 50/63] docs: standardizing capitalization --- docs-source/forms-source/form1-doc/complex.md | 2 +- .../forms-source/form1-doc/copying-arrays.md | 2 +- docs-source/forms-source/form1-doc/functions.md | 10 +++++----- docs-source/forms-source/form1-doc/looping.md | 2 +- docs/FIRST-FORM.md | 16 ++++++++-------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs-source/forms-source/form1-doc/complex.md b/docs-source/forms-source/form1-doc/complex.md index 5334eea..fe167df 100644 --- a/docs-source/forms-source/form1-doc/complex.md +++ b/docs-source/forms-source/form1-doc/complex.md @@ -6,7 +6,7 @@ You will use previous functions chained to gether to give us new results. -### sumOfSquares function ### +### Sum Of Squares Function ### Create a function that takes an array of numbers, squares each number and then returns the sum of those squares. diff --git a/docs-source/forms-source/form1-doc/copying-arrays.md b/docs-source/forms-source/form1-doc/copying-arrays.md index 1e9382f..d719734 100644 --- a/docs-source/forms-source/form1-doc/copying-arrays.md +++ b/docs-source/forms-source/form1-doc/copying-arrays.md @@ -7,7 +7,7 @@ You are going to use functions to explore the `Array.prototype.slice` method. -### buildVector function ### +### Build Vector Function ### You will now create a function called `buildVector` that returns a copy of the array as it was passed. diff --git a/docs-source/forms-source/form1-doc/functions.md b/docs-source/forms-source/form1-doc/functions.md index 0296b3f..9c0bae5 100644 --- a/docs-source/forms-source/form1-doc/functions.md +++ b/docs-source/forms-source/form1-doc/functions.md @@ -7,7 +7,7 @@ Time to create functions and have them return a value. -### greeter function ### +### Greeter Function ### ##### It should say "Hello!" by default ##### @@ -35,7 +35,7 @@ Functions start with the keyword `function` followed by the name of the function -#### conditional logic [if/else] #### +#### Conditional Logic [If / Else] #### ##### It should say "Salutations!" when Salutations is passed ##### @@ -68,9 +68,9 @@ Add condition to greet to handle custom greeting case. -### function calls and mathematical operations [Math library] ### +### Function Calls and Mathematical Operations [Math Library] ### -#### square function #### +#### Square Function #### Create a function that takes a number and returns its square. @@ -140,7 +140,7 @@ Modify the `square` function such that it returns the square of the value passed -#### squareRoot function #### +#### Square Root Function #### Create a function that takes a number and returns the square root of that number. (note: use the Math library). diff --git a/docs-source/forms-source/form1-doc/looping.md b/docs-source/forms-source/form1-doc/looping.md index 7bdbcb9..079109c 100644 --- a/docs-source/forms-source/form1-doc/looping.md +++ b/docs-source/forms-source/form1-doc/looping.md @@ -5,7 +5,7 @@ /bl--> Now it is time to use functions to examine looping and comparisons. -### getVectorsShorterThan ### +### Get Vectors Shorter Than ### You will now create a function called `getVectorsShorterThan` that will take an array of arrays. It will compare each array based on its magnitude and return all arrays that have a magnitude smaller then the number provided. diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index 2a9388b..bfab2a5 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -246,7 +246,7 @@ Find `return {};` add a "b" -> `return {b};` Time to create functions and have them return a value. -### greeter function ### +### Greeter Function ### ##### It should say "Hello!" by default ##### @@ -274,7 +274,7 @@ Functions start with the keyword `function` followed by the name of the function -#### conditional logic [if/else] #### +#### Conditional Logic [If / Else] #### ##### It should say "Salutations!" when Salutations is passed ##### @@ -307,9 +307,9 @@ Add condition to greet to handle custom greeting case. -### function calls and mathematical operations [Math library] ### +### Function Calls and Mathematical Operations [Math Library] ### -#### square function #### +#### Square Function #### Create a function that takes a number and returns its square. @@ -379,7 +379,7 @@ Modify the `square` function such that it returns the square of the value passed -#### squareRoot function #### +#### Square Root Function #### Create a function that takes a number and returns the square root of that number. (note: use the Math library). @@ -621,7 +621,7 @@ Add logic to square all numbers in array (How did you solve sum?) You will use previous functions chained to gether to give us new results. -### sumOfSquares function ### +### Sum Of Squares Function ### Create a function that takes an array of numbers, squares each number and then returns the sum of those squares. @@ -686,7 +686,7 @@ Add logic to square all numbers and return the sum (squareAll and sum might be u You are going to use functions to explore the `Array.prototype.slice` method. -### buildVector function ### +### Build Vector Function ### You will now create a function called `buildVector` that returns a copy of the array as it was passed. @@ -916,7 +916,7 @@ The magnitude of a vector is computed by: ## Looping and inequality comparison ## Now it is time to use functions to examine looping and comparisons. -### getVectorsShorterThan ### +### Get Vectors Shorter Than ### You will now create a function called `getVectorsShorterThan` that will take an array of arrays. It will compare each array based on its magnitude and return all arrays that have a magnitude smaller then the number provided. From 0860fd0f2ed1aa029fc9918256c611682e7151fa Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 08:57:32 -0800 Subject: [PATCH 51/63] docs: unified quotation use --- .reset-files/4_test-dummy-form.test.js | 12 ++++---- .../forms-source/form1-doc/functions.md | 4 +-- docs-source/forms-source/form1-doc/looping.md | 2 +- .../form1-doc/variables/assignment.md | 6 ++-- .../form1-doc/variables/declaration.md | 4 +-- .../form1-doc/variables/exposingValues.md | 2 +- .../form1-doc/variables/methodCall.md | 2 +- .../forms-source/form2-doc/buildVector.md | 8 ++--- docs-source/forms-source/form2-doc/greeter.md | 2 +- .../forms-source/form3-doc/buildVector.md | 4 +-- docs-source/forms-source/form3-doc/greeter.md | 4 +-- .../pointOfSaleDataUtilityFactoryBuilder.md | 4 +-- .../form4-doc/getReport/getReturnsReport.md | 4 +-- .../form4-doc/getReport/getSalesReport.md | 22 +++++++------- docs/FIRST-FORM.md | 20 ++++++------- docs/SECOND-FORM.md | 10 +++---- docs/TEST-DUMMY-FORM.md | 30 +++++++++---------- docs/THIRD-FORM.md | 8 ++--- test/4_test-dummy-form.test.js | 12 ++++---- 19 files changed, 80 insertions(+), 80 deletions(-) diff --git a/.reset-files/4_test-dummy-form.test.js b/.reset-files/4_test-dummy-form.test.js index 4b09fce..904eff2 100644 --- a/.reset-files/4_test-dummy-form.test.js +++ b/.reset-files/4_test-dummy-form.test.js @@ -66,20 +66,20 @@ describe('Test Dummy Form - Costume Shop Sales', function () { describe('sales report', function () { describe('get sales report', function () { - it('returns a sales report with no sales'); + it('returns a report of sales with no sales'); - it('returns a sales report with one sale'); + it('returns a report of sales with one sale'); - it('returns a sales report with two sales of different products'); + it('returns a report of sales with two sales of different products'); - it('returns a sales report with two sales of the same product'); + it('returns a report of sales with two sales of the same product'); - it('returns a sales report with no "returns" data'); + it('returns a report of sales excluding any return transactions'); }); }); describe('returns report', function () { - it('returns a "returns" report with no "sales" data'); + it('returns a report of return transactions that excludes sales transactions'); }); }); diff --git a/docs-source/forms-source/form1-doc/functions.md b/docs-source/forms-source/form1-doc/functions.md index 9c0bae5..9a929b8 100644 --- a/docs-source/forms-source/form1-doc/functions.md +++ b/docs-source/forms-source/form1-doc/functions.md @@ -9,7 +9,7 @@ Time to create functions and have them return a value. ### Greeter Function ### -##### It should say "Hello!" by default ##### +##### It should say `"Hello!"` by default ##### Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") @@ -37,7 +37,7 @@ Functions start with the keyword `function` followed by the name of the function #### Conditional Logic [If / Else] #### -##### It should say "Salutations!" when Salutations is passed ##### +##### It should say `"Salutations!"` when salutations is passed ##### Modify the greet function to take a greeting and return the greeting if it was passed. diff --git a/docs-source/forms-source/form1-doc/looping.md b/docs-source/forms-source/form1-doc/looping.md index 079109c..b707938 100644 --- a/docs-source/forms-source/form1-doc/looping.md +++ b/docs-source/forms-source/form1-doc/looping.md @@ -17,7 +17,7 @@ getVectorsShorterThan(length, arrayOfVectors) Such that `length` is the number for which You will compare magnitudes against, and `arrayOfVectors` is the array of arrays, where then inner arrays are to contain numbers. -#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors #### +#### It returns an array of one vector when the vector is shorter than 5 #### Create a the function `getVectorsShorterThan` where the first parameter is `length` and the second parameter is `arrayOfVectors` that returns all vectors where the magnitude is less then 5. There is only one vector at this point and its length is less then 5. diff --git a/docs-source/forms-source/form1-doc/variables/assignment.md b/docs-source/forms-source/form1-doc/variables/assignment.md index e513d54..5641692 100644 --- a/docs-source/forms-source/form1-doc/variables/assignment.md +++ b/docs-source/forms-source/form1-doc/variables/assignment.md @@ -6,7 +6,7 @@ Now that you have a variable you will assign it a value different then what it was initialized with. -#### It should assign the sum of 3 and 7 (3 + 7) to "a" #### +#### It should assign the sum of 3 and 7 (3 + 7) to `a` #### Now assign variable `a` with the value of `3 + 7`. @@ -40,9 +40,9 @@ Add two numbers using the plus (+) operator -#### It should have a variable "b" initialized to "Hello, World!" #### +#### It should have a variable `b` initialized to `Hello, World!` #### -Create a variable called `b` and initialize it with the value `"Hello, World!" +Create a variable called `b` and initialize it with the value `"Hello, World!"`
Hints diff --git a/docs-source/forms-source/form1-doc/variables/declaration.md b/docs-source/forms-source/form1-doc/variables/declaration.md index 7379f13..c1b495c 100644 --- a/docs-source/forms-source/form1-doc/variables/declaration.md +++ b/docs-source/forms-source/form1-doc/variables/declaration.md @@ -6,7 +6,7 @@ Here you will declare and initialize variables. -#### It should have a variable called "a" #### +#### It should have a variable called `a` #### Create a variable at the top of the block called "a". You will need to use `let` or `var`. @@ -44,7 +44,7 @@ const jsforms = (function () {
-#### It should initialize "a" with the value 5 #### +#### It should initialize `a` with the value 5 #### Set the initial value of a to 5. diff --git a/docs-source/forms-source/form1-doc/variables/exposingValues.md b/docs-source/forms-source/form1-doc/variables/exposingValues.md index 69734c6..4d000b5 100644 --- a/docs-source/forms-source/form1-doc/variables/exposingValues.md +++ b/docs-source/forms-source/form1-doc/variables/exposingValues.md @@ -6,7 +6,7 @@ You well now expose values to the outside world. -#### It should expose variable "b" to be read outside of the module #### +#### It should expose variable `b` to be read outside of the module #### Expose the variable `b` to the outside world, by adding it the the object being exported. diff --git a/docs-source/forms-source/form1-doc/variables/methodCall.md b/docs-source/forms-source/form1-doc/variables/methodCall.md index cfe4c7a..fd8e570 100644 --- a/docs-source/forms-source/form1-doc/variables/methodCall.md +++ b/docs-source/forms-source/form1-doc/variables/methodCall.md @@ -5,7 +5,7 @@ /bl--> You will make a call to a method on an object. -#### It should log variable "b" to the console #### +#### It should log variable `b` to the console #### Use the `console.log` method to log the value contained in variable `b` to the console. diff --git a/docs-source/forms-source/form2-doc/buildVector.md b/docs-source/forms-source/form2-doc/buildVector.md index 8bec670..f6bad42 100644 --- a/docs-source/forms-source/form2-doc/buildVector.md +++ b/docs-source/forms-source/form2-doc/buildVector.md @@ -53,7 +53,7 @@ You will not be using JavaScripts class objects. Instead work from the original -#### It accepts a parameter "points" into Vector constructor #### +#### It accepts a parameter `points` into Vector constructor #### Modify the `Vector` function to take a parameter called points. There is no need to do anything with this parameter yet. @@ -74,7 +74,7 @@ The `Vector` constructor is just a function. All functions can have a name repre -#### It assigns `points` variable to "this.points" in `Vector` constructor #### +#### It assigns `points` variable to `this.points` in `Vector` constructor #### Modify the `Vector` constructor to save the `points` parameter. @@ -96,7 +96,7 @@ Remember in JavaScript, you do not have to predefine member variables before you -#### It overrides the valueOf function on the Vector prototype #### +#### It overrides the `valueOf` function on the Vector prototype #### Now you will need to override the internal `valueOf` function on `Vector`. Remember that `valueOf` comes from object and by default just returns the object. You will now change the behavior of this function to return a copy of its internal points. @@ -139,7 +139,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It should return a vector where toString returns a vector string #### +#### It should return a vector where `toString` returns a vector string #### You will modify the overridden `toString` method on `Vector` such that: diff --git a/docs-source/forms-source/form2-doc/greeter.md b/docs-source/forms-source/form2-doc/greeter.md index 23fa177..c16e47b 100644 --- a/docs-source/forms-source/form2-doc/greeter.md +++ b/docs-source/forms-source/form2-doc/greeter.md @@ -61,7 +61,7 @@ A ternary operator has the following form -#### It is refactored to use typeof comparison to "string" #### +#### It is refactored to use `typeof` comparison to `string` #### You will now modify the `greet` function to remove the `greeting === undefined` comparison and instead use the [typeof](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator to prove whether or not what was passed in was a string. diff --git a/docs-source/forms-source/form3-doc/buildVector.md b/docs-source/forms-source/form3-doc/buildVector.md index 308267f..a4662f0 100644 --- a/docs-source/forms-source/form3-doc/buildVector.md +++ b/docs-source/forms-source/form3-doc/buildVector.md @@ -241,7 +241,7 @@ You already have the code, you will just add it into a new function. -##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' ##### +##### It has a function called `assertArrayOfType` with a parameters `type` and `values` ##### Now create a function called `assertArrayOfType` that compares all items in `values` with the given `type` and throws an exception if any of the values are not the correct type. @@ -278,7 +278,7 @@ Again you already have this code. You just need to add it in the new function. -##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' ##### +##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument ##### Modify the `assertArrayOfType` function to call the `assertArray` function before it checks the values in the array. diff --git a/docs-source/forms-source/form3-doc/greeter.md b/docs-source/forms-source/form3-doc/greeter.md index 07e5142..bd94d47 100644 --- a/docs-source/forms-source/form3-doc/greeter.md +++ b/docs-source/forms-source/form3-doc/greeter.md @@ -36,7 +36,7 @@ This will use `typeOf` to do the check. -#### It calls isTypeOf from greet #### +#### It calls `isTypeOf` from greet #### Now you will modify the `greet` function to use the `isTypeOf` function instead of the `typeOf` function. @@ -92,7 +92,7 @@ You will want to use the new `isTypeOf` function. -#### It calls eitherOnType from greet #### +#### It calls `eitherOnType` from greet #### Modify the `greet` function so that you replace the trinary operator with the `eitherOnType` function. diff --git a/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md index 805ecd7..497320b 100644 --- a/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md +++ b/docs-source/forms-source/form4-doc/app/pointOfSaleDataUtilityFactoryBuilder.md @@ -20,7 +20,7 @@ These values are already set up for you. This function returns an object with two methods. -#### `getProductCountBySale` #### +#### Get Product Count by Sale #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -69,7 +69,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -#### `getProductCountByReturn` #### +#### Get Product Count by Return #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: diff --git a/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md index 51e8706..ef3f20e 100644 --- a/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getReturnsReport.md @@ -6,7 +6,7 @@ There is little to do in testing the "Returns" report because if you look at the code, it is almost entirely the same code as what creates the "Sales" report. So the only thing we have to do is test that it correctly filters when we ask for a report of the "Returns". -#### It returns a "returns" report with no "sales" data #### +#### It returns a report of return transactions that excludes sales transactions #### You will now create a test that will verify that the report is correct when you ask for it to give you a report of the returns. @@ -39,7 +39,7 @@ This will look very much like the last test but the transaction statuses are swa ```javascript describe('get returns report', function () { - it('returns a "returns" report with no "sales" data', () => { + it('returns a report of return transactions that excludes sales transactions', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); // This is the record that is not going to be counted transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); diff --git a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md index 61f51d9..124765d 100644 --- a/docs-source/forms-source/form4-doc/getReport/getSalesReport.md +++ b/docs-source/forms-source/form4-doc/getReport/getSalesReport.md @@ -21,7 +21,7 @@ Now when you write each test, you will follow the process you did before with on 6. Remove Guide comments 7. Refactor code if possible -#### It returns a sales report with no sales #### +#### It returns a report of sales with no sales #### Starting with a base case of there were no sales, you will write the test that proves that it returns a report with nothing in it. @@ -112,7 +112,7 @@ it('returns an empty object for sale counts if no sale data exists', () => { -#### It returns a sales report with one sale #### +#### It returns a report of sales with one sale #### Okay, the last test did a lot of heavy lifting for you. Now you will test the `getReport` function for a sales report with only one item sold. @@ -176,7 +176,7 @@ Once you have the `dataLoader` created, you will need to only change the Assert **Example** ```javascript -it('returns a sales report with one sale', () => { +it('returns a report of sales with one sale', () => { // Arrange let dataLoader = { getProductData: buildProductData, @@ -260,7 +260,7 @@ Bellow those, but still before the "get sales report" section, you will need to ##### Refactor Sales Report Tests Modify the First Test ##### -You need to change the first test, "returns a sales report with no sales", so that it uses the new suite level variables. +You need to change the first test, "returns a report of sales with no sales", so that it uses the new suite level variables.
Hints @@ -339,7 +339,7 @@ Most of the arrange in this test can be deleted. You will just need to add the s // ... - it('returns a sales report with one sale', () => { + it('returns a report of sales with one sale', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, 1)); let result = reportBuilder(transactionStatuses.Sale); @@ -356,7 +356,7 @@ Most of the arrange in this test can be deleted. You will just need to add the s
-#### It returns a sales report with two sales of different products #### +#### It returns a report of sales with two sales of different products #### Now you will test that the `getReport` can return a report with two different products. @@ -386,7 +386,7 @@ You will also have two objects in the result to test for. **Example** ```javascript -it('returns a sales report with two sales of different products', () => { +it('returns a report of sales with two sales of different products', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); @@ -411,7 +411,7 @@ it('returns a sales report with two sales of different products', () => { -#### It returns a sales report with two sales of the same product #### +#### It returns a report of sales with two sales of the same product #### You will test what happens if the transaction records have two different transactions for the sale of the same product. The result should represent the total of the quantity. @@ -439,7 +439,7 @@ There will only be a single object in the result. **Example** ```javascript -it('returns a sales report with two sales of the same product', () => { +it('returns a report of sales with two sales of the same product', () => { let productId = ?; transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); @@ -460,7 +460,7 @@ it('returns a sales report with two sales of the same product', () => { -#### It returns a sales report with no "returns" data #### +#### It returns a report of sales excluding any return transactions #### Now, you will verify that the `getReport` function filters according to the Sale transaction status. @@ -488,7 +488,7 @@ You are going to create the test very similarly to two tests ago, but you will a **Example** ```javascript -it('returns a sales report with no "returns" data', () => { +it('returns a report of sales excluding any return transactions', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); // This is the record that is not going to be counted transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index bfab2a5..25c74a0 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -27,7 +27,7 @@ You will explore the creation and use of variables. Here you will declare and initialize variables. -#### It should have a variable called "a" #### +#### It should have a variable called `a` #### Create a variable at the top of the block called "a". You will need to use `let` or `var`. @@ -65,7 +65,7 @@ const jsforms = (function () { -#### It should initialize "a" with the value 5 #### +#### It should initialize `a` with the value 5 #### Set the initial value of a to 5. @@ -108,7 +108,7 @@ const jsforms = (function () { Now that you have a variable you will assign it a value different then what it was initialized with. -#### It should assign the sum of 3 and 7 (3 + 7) to "a" #### +#### It should assign the sum of 3 and 7 (3 + 7) to `a` #### Now assign variable `a` with the value of `3 + 7`. @@ -142,9 +142,9 @@ Add two numbers using the plus (+) operator -#### It should have a variable "b" initialized to "Hello, World!" #### +#### It should have a variable `b` initialized to `Hello, World!` #### -Create a variable called `b` and initialize it with the value `"Hello, World!" +Create a variable called `b` and initialize it with the value `"Hello, World!"`
Hints @@ -178,7 +178,7 @@ Initialize a variable with equals: `var b = ...` ### Method Call ### You will make a call to a method on an object. -#### It should log variable "b" to the console #### +#### It should log variable `b` to the console #### Use the `console.log` method to log the value contained in variable `b` to the console. @@ -216,7 +216,7 @@ Console.log might be just the ticket... You well now expose values to the outside world. -#### It should expose variable "b" to be read outside of the module #### +#### It should expose variable `b` to be read outside of the module #### Expose the variable `b` to the outside world, by adding it the the object being exported. @@ -248,7 +248,7 @@ Time to create functions and have them return a value. ### Greeter Function ### -##### It should say "Hello!" by default ##### +##### It should say `"Hello!"` by default ##### Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") @@ -276,7 +276,7 @@ Functions start with the keyword `function` followed by the name of the function #### Conditional Logic [If / Else] #### -##### It should say "Salutations!" when Salutations is passed ##### +##### It should say `"Salutations!"` when salutations is passed ##### Modify the greet function to take a greeting and return the greeting if it was passed. @@ -928,7 +928,7 @@ getVectorsShorterThan(length, arrayOfVectors) Such that `length` is the number for which You will compare magnitudes against, and `arrayOfVectors` is the array of arrays, where then inner arrays are to contain numbers. -#### It returns an array of one vector when the vector is shorter than 5 -- arguments are: length, arrayOfVectors #### +#### It returns an array of one vector when the vector is shorter than 5 #### Create a the function `getVectorsShorterThan` where the first parameter is `length` and the second parameter is `arrayOfVectors` that returns all vectors where the magnitude is less then 5. There is only one vector at this point and its length is less then 5. diff --git a/docs/SECOND-FORM.md b/docs/SECOND-FORM.md index d814d8a..1a57c71 100644 --- a/docs/SECOND-FORM.md +++ b/docs/SECOND-FORM.md @@ -78,7 +78,7 @@ A ternary operator has the following form
-#### It is refactored to use typeof comparison to "string" #### +#### It is refactored to use `typeof` comparison to `string` #### You will now modify the `greet` function to remove the `greeting === undefined` comparison and instead use the [typeof](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof) operator to prove whether or not what was passed in was a string. @@ -342,7 +342,7 @@ You will not be using JavaScripts class objects. Instead work from the original -#### It accepts a parameter "points" into Vector constructor #### +#### It accepts a parameter `points` into Vector constructor #### Modify the `Vector` function to take a parameter called points. There is no need to do anything with this parameter yet. @@ -363,7 +363,7 @@ The `Vector` constructor is just a function. All functions can have a name repre -#### It assigns `points` variable to "this.points" in `Vector` constructor #### +#### It assigns `points` variable to `this.points` in `Vector` constructor #### Modify the `Vector` constructor to save the `points` parameter. @@ -385,7 +385,7 @@ Remember in JavaScript, you do not have to predefine member variables before you -#### It overrides the valueOf function on the Vector prototype #### +#### It overrides the `valueOf` function on the Vector prototype #### Now you will need to override the internal `valueOf` function on `Vector`. Remember that `valueOf` comes from object and by default just returns the object. You will now change the behavior of this function to return a copy of its internal points. @@ -428,7 +428,7 @@ The way to override an internal function in JavaScript without the use of the `c -#### It should return a vector where toString returns a vector string #### +#### It should return a vector where `toString` returns a vector string #### You will modify the overridden `toString` method on `Vector` such that: diff --git a/docs/TEST-DUMMY-FORM.md b/docs/TEST-DUMMY-FORM.md index dc7e44f..0bae488 100644 --- a/docs/TEST-DUMMY-FORM.md +++ b/docs/TEST-DUMMY-FORM.md @@ -67,7 +67,7 @@ These values are already set up for you. This function returns an object with two methods. -#### `getProductCountBySale` #### +#### Get Product Count by Sale #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -116,7 +116,7 @@ The result should look like the following: Because there is a total of 5 items sold of Product ID 3, and only 4 items sold of Product ID 6. -#### `getProductCountByReturn` #### +#### Get Product Count by Return #### This method takes the parameter `transactionRecords` which is an array of transaction records. Each record is expected to have the following shape: @@ -1401,7 +1401,7 @@ Now when you write each test, you will follow the process you did before with on 6. Remove Guide comments 7. Refactor code if possible -#### It returns a sales report with no sales #### +#### It returns a report of sales with no sales #### Starting with a base case of there were no sales, you will write the test that proves that it returns a report with nothing in it. @@ -1492,7 +1492,7 @@ it('returns an empty object for sale counts if no sale data exists', () => { -#### It returns a sales report with one sale #### +#### It returns a report of sales with one sale #### Okay, the last test did a lot of heavy lifting for you. Now you will test the `getReport` function for a sales report with only one item sold. @@ -1556,7 +1556,7 @@ Once you have the `dataLoader` created, you will need to only change the Assert **Example** ```javascript -it('returns a sales report with one sale', () => { +it('returns a report of sales with one sale', () => { // Arrange let dataLoader = { getProductData: buildProductData, @@ -1640,7 +1640,7 @@ Bellow those, but still before the "get sales report" section, you will need to ##### Refactor Sales Report Tests Modify the First Test ##### -You need to change the first test, "returns a sales report with no sales", so that it uses the new suite level variables. +You need to change the first test, "returns a report of sales with no sales", so that it uses the new suite level variables.
Hints @@ -1719,7 +1719,7 @@ Most of the arrange in this test can be deleted. You will just need to add the s // ... - it('returns a sales report with one sale', () => { + it('returns a report of sales with one sale', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, 1)); let result = reportBuilder(transactionStatuses.Sale); @@ -1736,7 +1736,7 @@ Most of the arrange in this test can be deleted. You will just need to add the s
-#### It returns a sales report with two sales of different products #### +#### It returns a report of sales with two sales of different products #### Now you will test that the `getReport` can return a report with two different products. @@ -1766,7 +1766,7 @@ You will also have two objects in the result to test for. **Example** ```javascript -it('returns a sales report with two sales of different products', () => { +it('returns a report of sales with two sales of different products', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); @@ -1791,7 +1791,7 @@ it('returns a sales report with two sales of different products', () => { -#### It returns a sales report with two sales of the same product #### +#### It returns a report of sales with two sales of the same product #### You will test what happens if the transaction records have two different transactions for the sale of the same product. The result should represent the total of the quantity. @@ -1819,7 +1819,7 @@ There will only be a single object in the result. **Example** ```javascript -it('returns a sales report with two sales of the same product', () => { +it('returns a report of sales with two sales of the same product', () => { let productId = ?; transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(productId, transactionStatuses.Sale, ?)); @@ -1840,7 +1840,7 @@ it('returns a sales report with two sales of the same product', () => { -#### It returns a sales report with no "returns" data #### +#### It returns a report of sales excluding any return transactions #### Now, you will verify that the `getReport` function filters according to the Sale transaction status. @@ -1868,7 +1868,7 @@ You are going to create the test very similarly to two tests ago, but you will a **Example** ```javascript -it('returns a sales report with no "returns" data', () => { +it('returns a report of sales excluding any return transactions', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); // This is the record that is not going to be counted transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); @@ -1899,7 +1899,7 @@ it('returns a sales report with no "returns" data', () => { There is little to do in testing the "Returns" report because if you look at the code, it is almost entirely the same code as what creates the "Sales" report. So the only thing we have to do is test that it correctly filters when we ask for a report of the "Returns". -#### It returns a "returns" report with no "sales" data #### +#### It returns a report of return transactions that excludes sales transactions #### You will now create a test that will verify that the report is correct when you ask for it to give you a report of the returns. @@ -1932,7 +1932,7 @@ This will look very much like the last test but the transaction statuses are swa ```javascript describe('get returns report', function () { - it('returns a "returns" report with no "sales" data', () => { + it('returns a report of return transactions that excludes sales transactions', () => { transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Sale, ?)); // This is the record that is not going to be counted transactionRecords.push(buildTransactionRecord(?, transactionStatuses.Return, ?)); diff --git a/docs/THIRD-FORM.md b/docs/THIRD-FORM.md index 2e30fa9..3e52356 100644 --- a/docs/THIRD-FORM.md +++ b/docs/THIRD-FORM.md @@ -51,7 +51,7 @@ This will use `typeOf` to do the check. -#### It calls isTypeOf from greet #### +#### It calls `isTypeOf` from greet #### Now you will modify the `greet` function to use the `isTypeOf` function instead of the `typeOf` function. @@ -107,7 +107,7 @@ You will want to use the new `isTypeOf` function. -#### It calls eitherOnType from greet #### +#### It calls `eitherOnType` from greet #### Modify the `greet` function so that you replace the trinary operator with the `eitherOnType` function. @@ -466,7 +466,7 @@ You already have the code, you will just add it into a new function. -##### It has a function called `assertArrayOfType` with a parameters `type` and `values`' ##### +##### It has a function called `assertArrayOfType` with a parameters `type` and `values` ##### Now create a function called `assertArrayOfType` that compares all items in `values` with the given `type` and throws an exception if any of the values are not the correct type. @@ -503,7 +503,7 @@ Again you already have this code. You just need to add it in the new function. -##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument' ##### +##### It has a call in `assertArrayOfType` function to `assertArray` with `values` as an argument ##### Modify the `assertArrayOfType` function to call the `assertArray` function before it checks the values in the array. diff --git a/test/4_test-dummy-form.test.js b/test/4_test-dummy-form.test.js index 52ab0ff..beb48e9 100644 --- a/test/4_test-dummy-form.test.js +++ b/test/4_test-dummy-form.test.js @@ -69,19 +69,19 @@ describe('Test Dummy Form - Costume Shop Sales', function () { // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js describe('get sales report', function () { - it('returns a sales report with no sales'); + it('returns a report of sales with no sales'); - it('returns a sales report with one sale'); + it('returns a report of sales with one sale'); - it('returns a sales report with two sales of different products'); + it('returns a report of sales with two sales of different products'); - it('returns a sales report with two sales of the same product'); + it('returns a report of sales with two sales of the same product'); - it('returns a sales report with no "returns" data'); + it('returns a report of sales excluding any return transactions'); }); describe('get returns report', function () { - it('returns a "returns" report with no "sales" data'); + it('returns a report of return transactions that excludes sales transactions'); }); }); }); From 9fa1941f9be44bf2c65e37b96fe28bec541ef50b Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 09:17:47 -0800 Subject: [PATCH 52/63] docs: breaking up form1 functions --- docs-source/forms-source/form1-doc/_main.md | 2 +- .../forms-source/form1-doc/{functions.md => functions/_main.md} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs-source/forms-source/form1-doc/{functions.md => functions/_main.md} (100%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 1a025c1..e95ba36 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -13,7 +13,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 + You will use functions to work with arrays and loops. ### Sum Function ### diff --git a/docs-source/forms-source/form1-doc/functions/_main.md b/docs-source/forms-source/form1-doc/functions/_main.md index 9a929b8..e3e8ddc 100644 --- a/docs-source/forms-source/form1-doc/functions/_main.md +++ b/docs-source/forms-source/form1-doc/functions/_main.md @@ -6,193 +6,7 @@ /bl--> Time to create functions and have them return a value. - -### Greeter Function ### - -##### It should say `"Hello!"` by default ##### - -Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") - -
Hints - -Functions start with the keyword `function` followed by the name of the function and then a set of parenthesis `()`. All the logic of a function is contained an open curly brace `{` and a closed curly brace `}`. What the function returns follows the key word `return`. - -
Code - -**Example** - -```javascript - function greet() { - return _string_; - } - - return { - greet, - }; -``` - -
- -
- -#### Conditional Logic [If / Else] #### - -##### It should say `"Salutations!"` when salutations is passed ##### - -Modify the greet function to take a greeting and return the greeting if it was passed. - -
Hints - -Add condition to greet to handle custom greeting case. -(Try using an "if/else" structure. "If" is a control structure) - -
Code - -**Example** - -```javascript - function greet (greeting) { - if (_something_ === undefined) { - return _string_; - } else { - return _something_ + '!'; - } - } - - return { - greet, - }; -``` - -
- -
- -### Function Calls and Mathematical Operations [Math Library] ### - -#### Square Function #### - -Create a function that takes a number and returns its square. - -##### It should square 1 ##### - -The function called `square` will be passed 1 and should return 1. - -
Hints - -Add square function that returns a simple value rather then worrying about actually squaring the a value. - -
Code - -**Example** - -```javascript - function square(_something_) { - return ?; - } - - return { - square, - }; -``` - -
- -
- -##### It should square 3 ##### - -Modify the `square` function such that it returns the square of the value passed in. - -
Hints - -1. Add logic to correctly square a number (remember n^2 <=> n * n) -2. Move to library function to perform square operation - 1. Math is a built in library... - -
Code - -**Example 1** - -```javascript - function square(_something_) { - return ? * ?; - } - - return { - square, - }; -``` - -**Example 2** - -```javascript - function square(_something_) { - return Math.pow(?, 2); - } - - return { - square, - }; -``` - -
- -
- -#### Square Root Function #### - -Create a function that takes a number and returns the square root of that number. (note: use the Math library). - -##### It should take the square root of 1 ##### - -Create a function called `squareRoot` that will be passed 1 and return 1. - -
Hints - -Create a function that returns a simple value rather then worrying about actually performing a square root of the value. - -
Code - -**Example** - -```javascript - function squareRoot(_something_) { - return ?; - } - - return { - squareRoot, - }; -``` - -
- -
- -##### It should take the square root of 4 ##### - -Modify the `squareRoot` function to return the square root of the value passed. - -
Hints - -Add logic to properly take square root -(There is more than one way to solve this in one line, maybe with Math) - -
Code - -**Example** - -```javascript - function squareRoot(_something_) { - return Math.sqrt(_something_); - } - - return { - squareRoot, - }; -``` - -
- -
\ No newline at end of file + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/functions/functionCalls.md b/docs-source/forms-source/form1-doc/functions/functionCalls.md new file mode 100644 index 0000000..1a15a19 --- /dev/null +++ b/docs-source/forms-source/form1-doc/functions/functionCalls.md @@ -0,0 +1,132 @@ + + +#### Square Function #### + +Create a function that takes a number and returns its square. + +##### It should square 1 ##### + +The function called `square` will be passed 1 and should return 1. + +
Hints + +Add square function that returns a simple value rather then worrying about actually squaring the a value. + +
Code + +**Example** + +```javascript + function square(_something_) { + return ?; + } + + return { + square, + }; +``` + +
+ +
+ +##### It should square 3 ##### + +Modify the `square` function such that it returns the square of the value passed in. + +
Hints + +1. Add logic to correctly square a number (remember n^2 <=> n * n) +2. Move to library function to perform square operation + 1. Math is a built in library... + +
Code + +**Example 1** + +```javascript + function square(_something_) { + return ? * ?; + } + + return { + square, + }; +``` + +**Example 2** + +```javascript + function square(_something_) { + return Math.pow(?, 2); + } + + return { + square, + }; +``` + +
+ +
+ +#### Square Root Function #### + +Create a function that takes a number and returns the square root of that number. (note: use the Math library). + +##### It should take the square root of 1 ##### + +Create a function called `squareRoot` that will be passed 1 and return 1. + +
Hints + +Create a function that returns a simple value rather then worrying about actually performing a square root of the value. + +
Code + +**Example** + +```javascript + function squareRoot(_something_) { + return ?; + } + + return { + squareRoot, + }; +``` + +
+ +
+ +##### It should take the square root of 4 ##### + +Modify the `squareRoot` function to return the square root of the value passed. + +
Hints + +Add logic to properly take square root +(There is more than one way to solve this in one line, maybe with Math) + +
Code + +**Example** + +```javascript + function squareRoot(_something_) { + return Math.sqrt(_something_); + } + + return { + squareRoot, + }; +``` + +
+ +
\ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/functions/greeterFunction.md b/docs-source/forms-source/form1-doc/functions/greeterFunction.md new file mode 100644 index 0000000..1b34239 --- /dev/null +++ b/docs-source/forms-source/form1-doc/functions/greeterFunction.md @@ -0,0 +1,64 @@ + + +#### It should say `"Hello!"` by default #### + +Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") + +
Hints + +Functions start with the keyword `function` followed by the name of the function and then a set of parenthesis `()`. All the logic of a function is contained an open curly brace `{` and a closed curly brace `}`. What the function returns follows the key word `return`. + +
Code + +**Example** + +```javascript + function greet() { + return _string_; + } + + return { + greet, + }; +``` + +
+ +
+ +#### Conditional Logic [If / Else] #### + +##### It should say `"Salutations!"` when salutations is passed ##### + +Modify the greet function to take a greeting and return the greeting if it was passed. + +
Hints + +Add condition to greet to handle custom greeting case. +(Try using an "if/else" structure. "If" is a control structure) + +
Code + +**Example** + +```javascript + function greet (greeting) { + if (_something_ === undefined) { + return _string_; + } else { + return _something_ + '!'; + } + } + + return { + greet, + }; +``` + +
+ +
\ No newline at end of file diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index 25c74a0..fd8e523 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -248,7 +248,7 @@ Time to create functions and have them return a value. ### Greeter Function ### -##### It should say `"Hello!"` by default ##### +#### It should say `"Hello!"` by default #### Write a function called `greet` that returns the value "Hello!". (note: don't forget the "!") @@ -306,6 +306,7 @@ Add condition to greet to handle custom greeting case. + ### Function Calls and Mathematical Operations [Math Library] ### @@ -436,8 +437,10 @@ Add logic to properly take square root + ## Arrays, Loops, and Function Calls ## + You will use functions to work with arrays and loops. ### Sum Function ### From 0181ba8ae06bb768a5943f9c8d945d34649a86bb Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 09:31:53 -0800 Subject: [PATCH 54/63] docs: broke up form1 arrays --- docs-source/forms-source/form1-doc/_main.md | 3 +- .../forms-source/form1-doc/arrays/_main.md | 11 +++ .../forms-source/form1-doc/arrays/square.md | 69 ++++++++++++++++++ .../form1-doc/{arrays.md => arrays/sum.md} | 72 +------------------ docs/FIRST-FORM.md | 3 +- 5 files changed, 84 insertions(+), 74 deletions(-) create mode 100644 docs-source/forms-source/form1-doc/arrays/_main.md create mode 100644 docs-source/forms-source/form1-doc/arrays/square.md rename docs-source/forms-source/form1-doc/{arrays.md => arrays/sum.md} (55%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index e95ba36..19797ec 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -9,12 +9,11 @@ You can also look at [JS Learner Forms documentation](../FORMS.md) for other forms. You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1_first-form.js) file. - + +You will use functions to work with arrays and loops. + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/arrays/square.md b/docs-source/forms-source/form1-doc/arrays/square.md new file mode 100644 index 0000000..c1ba9d3 --- /dev/null +++ b/docs-source/forms-source/form1-doc/arrays/square.md @@ -0,0 +1,69 @@ + + +Create a function that squares each number in an array. + +The steps you will take to building the `squareAll` function are: + +1. Add a `squareAll` function that returns a constant value. +2. Chang the `squareAll` function to perform square computation on array value + +#### It should square all numbers in a single-value array #### + +Create a function called `squareAll` that takes an array and returns the square of the first element. + +
Hints + +Create a function that only squares the first value of an array and returns that value as an array. + +
Code + +**Example** + +```javascript + function squareAll (values) { + let result = square(_array_[_number_]); + return [_something_]; + } + + return { + squareAll, + }; +``` + +
+ +
+ +#### It should square multiple numbers #### + +Modify the `squareAll` function so that it now squares each number in the array. + +
Hints + +Add logic to square all numbers in array (How did you solve sum?) + +
Code + +**Example** + +```javascript + function squareAll (values) { + for(let index = _number_; _number_ < _number_; index += 1) { + result[index] = square(_something_[index]); + } + + return ?; + } + + return { + squareAll, + }; +``` + +
+ +
\ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/arrays.md b/docs-source/forms-source/form1-doc/arrays/sum.md similarity index 55% rename from docs-source/forms-source/form1-doc/arrays.md rename to docs-source/forms-source/form1-doc/arrays/sum.md index a3a51c9..82f0c72 100644 --- a/docs-source/forms-source/form1-doc/arrays.md +++ b/docs-source/forms-source/form1-doc/arrays/sum.md @@ -1,13 +1,9 @@ -You will use functions to work with arrays and loops. - -### Sum Function ### - You are going to create a function called `sum` that adds numbers together. #### It should take the sum of one number #### @@ -114,70 +110,4 @@ Add logic to sum an arbitrary length array of numbers (A for loop might help to - - -### Square All Function ### - -Create a function that squares each number in an array. - -The steps you will take to building the `squareAll` function are: - -1. Add a `squareAll` function that returns a constant value. -2. Chang the `squareAll` function to perform square computation on array value - -#### It should square all numbers in a single-value array #### - -Create a function called `squareAll` that takes an array and returns the square of the first element. - -
Hints - -Create a function that only squares the first value of an array and returns that value as an array. - -
Code - -**Example** - -```javascript - function squareAll (values) { - let result = square(_array_[_number_]); - return [_something_]; - } - - return { - squareAll, - }; -``` - -
- -
- -#### It should square multiple numbers #### - -Modify the `squareAll` function so that it now squares each number in the array. - -
Hints - -Add logic to square all numbers in array (How did you solve sum?) - -
Code - -**Example** - -```javascript - function squareAll (values) { - for(let index = _number_; _number_ < _number_; index += 1) { - result[index] = square(_something_[index]); - } - - return ?; - } - - return { - squareAll, - }; -``` - -
-
\ No newline at end of file diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index fd8e523..9faa1d5 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -7,7 +7,6 @@ You can also look at [JS Learner Forms documentation](../FORMS.md) for other for You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1_first-form.js) file. - ## Table Of Contents ## - [Section 1: Variables and Operations](#user-content-variables-and-operations) @@ -552,6 +551,7 @@ Add logic to sum an arbitrary length array of numbers (A for loop might help to + ### Square All Function ### @@ -619,6 +619,7 @@ Add logic to square all numbers in array (How did you solve sum?) + ## Combining Complex Functions ## From 7a38349895c8650ffd6622a0521c6d9bb22efdd1 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 10:02:48 -0800 Subject: [PATCH 55/63] docs: broke out complex form1 --- docs-source/forms-source/form1-doc/_main.md | 2 +- docs-source/forms-source/form1-doc/complex/_main.md | 10 ++++++++++ .../form1-doc/{complex.md => complex/sumOfSquares.md} | 6 +----- docs-source/forms-source/form1-doc/functions/_main.md | 3 +-- docs-source/forms-source/form1-doc/looping.md | 1 + .../forms-source/form1-doc/variables/exposingValues.md | 2 +- .../forms-source/form1-doc/variables/methodCall.md | 2 +- docs/FIRST-FORM.md | 9 ++++----- 8 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 docs-source/forms-source/form1-doc/complex/_main.md rename docs-source/forms-source/form1-doc/{complex.md => complex/sumOfSquares.md} (89%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 19797ec..84406ac 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -14,7 +14,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 (section-main "./variables/_main.md") (section-main "./functions/_main.md") (section-main "./arrays/_main.md") - (section-main "./complex.md") + (section-main "./complex/_main.md") (section-main "./copying-arrays.md") (section-main "./combining.md") (section-main "./looping.md") diff --git a/docs-source/forms-source/form1-doc/complex/_main.md b/docs-source/forms-source/form1-doc/complex/_main.md new file mode 100644 index 0000000..59eb8cb --- /dev/null +++ b/docs-source/forms-source/form1-doc/complex/_main.md @@ -0,0 +1,10 @@ + + +You will use previous functions chained to gether to give us new results. + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/complex.md b/docs-source/forms-source/form1-doc/complex/sumOfSquares.md similarity index 89% rename from docs-source/forms-source/form1-doc/complex.md rename to docs-source/forms-source/form1-doc/complex/sumOfSquares.md index fe167df..d438f60 100644 --- a/docs-source/forms-source/form1-doc/complex.md +++ b/docs-source/forms-source/form1-doc/complex/sumOfSquares.md @@ -1,13 +1,9 @@ -You will use previous functions chained to gether to give us new results. - -### Sum Of Squares Function ### - Create a function that takes an array of numbers, squares each number and then returns the sum of those squares. #### It should square number in a 1-length array and return it #### diff --git a/docs-source/forms-source/form1-doc/functions/_main.md b/docs-source/forms-source/form1-doc/functions/_main.md index e3e8ddc..b245d8c 100644 --- a/docs-source/forms-source/form1-doc/functions/_main.md +++ b/docs-source/forms-source/form1-doc/functions/_main.md @@ -1,7 +1,6 @@ diff --git a/docs-source/forms-source/form1-doc/looping.md b/docs-source/forms-source/form1-doc/looping.md index b707938..d56a1b9 100644 --- a/docs-source/forms-source/form1-doc/looping.md +++ b/docs-source/forms-source/form1-doc/looping.md @@ -3,6 +3,7 @@ (title "Looping and inequality comparison") ) /bl--> + Now it is time to use functions to examine looping and comparisons. ### Get Vectors Shorter Than ### diff --git a/docs-source/forms-source/form1-doc/variables/exposingValues.md b/docs-source/forms-source/form1-doc/variables/exposingValues.md index 4d000b5..815f4e7 100644 --- a/docs-source/forms-source/form1-doc/variables/exposingValues.md +++ b/docs-source/forms-source/form1-doc/variables/exposingValues.md @@ -26,4 +26,4 @@ Find `return {};` add a "b" -> `return {b};` - + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/variables/methodCall.md b/docs-source/forms-source/form1-doc/variables/methodCall.md index fd8e570..f665d8a 100644 --- a/docs-source/forms-source/form1-doc/variables/methodCall.md +++ b/docs-source/forms-source/form1-doc/variables/methodCall.md @@ -35,4 +35,4 @@ Console.log might be just the ticket... - + \ No newline at end of file diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index 9faa1d5..511f463 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -10,7 +10,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 ## Table Of Contents ## - [Section 1: Variables and Operations](#user-content-variables-and-operations) -- [Section 2: Function Creation](#user-content-function-creation) +- [Section 2: Function Creation, Function Declaration, and the Return Statement](#user-content-function-creation,-function-declaration,-and-the-return-statement) - [Section 3: Arrays, Loops, and Function Calls](#user-content-arrays,-loops,-and-function-calls) - [Section 4: Combining Complex Functions](#user-content-combining-complex-functions) - [Section 5: Copying Arrays](#user-content-copying-arrays) @@ -208,7 +208,6 @@ Console.log might be just the ticket... - ### Exposing Values ### @@ -236,12 +235,10 @@ Find `return {};` add a "b" -> `return {b};` - -## Function Creation ## -#### [function declaration, return statement] #### +## Function Creation, Function Declaration, and the Return Statement ## Time to create functions and have them return a value. @@ -684,6 +681,7 @@ Add logic to square all numbers and return the sum (squareAll and sum might be u + ## Copying Arrays ## #### Using Array.slice #### @@ -918,6 +916,7 @@ The magnitude of a vector is computed by: ## Looping and inequality comparison ## + Now it is time to use functions to examine looping and comparisons. ### Get Vectors Shorter Than ### From c44512452b64200388b50bbea444f14de32aa867 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 10:08:27 -0800 Subject: [PATCH 56/63] docs: broke up copying-arrays --- docs-source/forms-source/form1-doc/_main.md | 2 +- .../forms-source/form1-doc/copying-arrays/_main.md | 10 ++++++++++ .../buildVector.md} | 7 +------ docs/FIRST-FORM.md | 6 +++--- 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 docs-source/forms-source/form1-doc/copying-arrays/_main.md rename docs-source/forms-source/form1-doc/{copying-arrays.md => copying-arrays/buildVector.md} (88%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 84406ac..46e1baf 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -15,7 +15,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 (section-main "./functions/_main.md") (section-main "./arrays/_main.md") (section-main "./complex/_main.md") - (section-main "./copying-arrays.md") + (section-main "./copying-arrays/_main.md") (section-main "./combining.md") (section-main "./looping.md") (section-main "./otherForms.md") diff --git a/docs-source/forms-source/form1-doc/copying-arrays/_main.md b/docs-source/forms-source/form1-doc/copying-arrays/_main.md new file mode 100644 index 0000000..7304aad --- /dev/null +++ b/docs-source/forms-source/form1-doc/copying-arrays/_main.md @@ -0,0 +1,10 @@ + + +You are going to use functions to explore the `Array.prototype.slice` method. + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/copying-arrays.md b/docs-source/forms-source/form1-doc/copying-arrays/buildVector.md similarity index 88% rename from docs-source/forms-source/form1-doc/copying-arrays.md rename to docs-source/forms-source/form1-doc/copying-arrays/buildVector.md index d719734..fe31a8b 100644 --- a/docs-source/forms-source/form1-doc/copying-arrays.md +++ b/docs-source/forms-source/form1-doc/copying-arrays/buildVector.md @@ -1,14 +1,9 @@ -You are going to use functions to explore the `Array.prototype.slice` method. - -### Build Vector Function ### - You will now create a function called `buildVector` that returns a copy of the array as it was passed. > A vector is an ordered set of points which describes a "directed line segment," in other words, a vector is a line segment with an arrow diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index 511f463..a18d8df 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -13,7 +13,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 - [Section 2: Function Creation, Function Declaration, and the Return Statement](#user-content-function-creation,-function-declaration,-and-the-return-statement) - [Section 3: Arrays, Loops, and Function Calls](#user-content-arrays,-loops,-and-function-calls) - [Section 4: Combining Complex Functions](#user-content-combining-complex-functions) -- [Section 5: Copying Arrays](#user-content-copying-arrays) +- [Section 5: Copying Arrays Using `Array.slice`](#user-content-copying-arrays-using-`array.slice`) - [Section 6: Combining existing code to solve new problems](#user-content-combining-existing-code-to-solve-new-problems) - [Section 7: Looping and inequality comparison](#user-content-looping-and-inequality-comparison) - [Section 8: The Other JS Learner Forms](#user-content-the-other-js-learner-forms) @@ -683,8 +683,7 @@ Add logic to square all numbers and return the sum (squareAll and sum might be u -## Copying Arrays ## -#### Using Array.slice #### +## Copying Arrays Using `Array.slice` ## You are going to use functions to explore the `Array.prototype.slice` method. @@ -747,6 +746,7 @@ Add logic to return a copy of vector array (Slice will create a new array just l + ## Combining existing code to solve new problems ## You will now take code you wrote and use it define more complex behaviors From 912be004d9c26baea23b64310bd7dfa0f7129e55 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 12:50:52 -0800 Subject: [PATCH 57/63] docs: broke up combining form1 --- docs-source/forms-source/form1-doc/_main.md | 2 +- docs-source/forms-source/form1-doc/combining/_main.md | 10 ++++++++++ .../form1-doc/{combining.md => combining/magnitude.md} | 5 +---- docs/FIRST-FORM.md | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 docs-source/forms-source/form1-doc/combining/_main.md rename docs-source/forms-source/form1-doc/{combining.md => combining/magnitude.md} (95%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 46e1baf..9db5ff7 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -16,7 +16,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 (section-main "./arrays/_main.md") (section-main "./complex/_main.md") (section-main "./copying-arrays/_main.md") - (section-main "./combining.md") + (section-main "./combining/_main.md") (section-main "./looping.md") (section-main "./otherForms.md") ) diff --git a/docs-source/forms-source/form1-doc/combining/_main.md b/docs-source/forms-source/form1-doc/combining/_main.md new file mode 100644 index 0000000..8c47383 --- /dev/null +++ b/docs-source/forms-source/form1-doc/combining/_main.md @@ -0,0 +1,10 @@ + + +You will now take code you wrote and use it define more complex behaviors + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/combining.md b/docs-source/forms-source/form1-doc/combining/magnitude.md similarity index 95% rename from docs-source/forms-source/form1-doc/combining.md rename to docs-source/forms-source/form1-doc/combining/magnitude.md index e7953b9..0169805 100644 --- a/docs-source/forms-source/form1-doc/combining.md +++ b/docs-source/forms-source/form1-doc/combining/magnitude.md @@ -1,11 +1,8 @@ -You will now take code you wrote and use it define more complex behaviors - -### Magnitude Function ### You will create a function called `magnitude` that will calculate the magnitude of all given numbers. diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index a18d8df..b7ec60a 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -749,6 +749,7 @@ Add logic to return a copy of vector array (Slice will create a new array just l ## Combining existing code to solve new problems ## + You will now take code you wrote and use it define more complex behaviors ### Magnitude Function ### @@ -914,6 +915,7 @@ The magnitude of a vector is computed by: + ## Looping and inequality comparison ## From 48a0db7b26a92983f25eb35bb8974a8fa746160a Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 13:00:34 -0800 Subject: [PATCH 58/63] docs: broke up looping form1 --- docs-source/forms-source/form1-doc/_main.md | 2 +- docs-source/forms-source/form1-doc/looping/_main.md | 10 ++++++++++ .../{looping.md => looping/vectorsShorterThan.md} | 8 ++------ docs/FIRST-FORM.md | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 docs-source/forms-source/form1-doc/looping/_main.md rename docs-source/forms-source/form1-doc/{looping.md => looping/vectorsShorterThan.md} (95%) diff --git a/docs-source/forms-source/form1-doc/_main.md b/docs-source/forms-source/form1-doc/_main.md index 9db5ff7..5765090 100644 --- a/docs-source/forms-source/form1-doc/_main.md +++ b/docs-source/forms-source/form1-doc/_main.md @@ -17,7 +17,7 @@ You will be working in then [jsforms-source/1_first-form.js](..\jsforms-source\1 (section-main "./complex/_main.md") (section-main "./copying-arrays/_main.md") (section-main "./combining/_main.md") - (section-main "./looping.md") + (section-main "./looping/_main.md") (section-main "./otherForms.md") ) /bl--> \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/looping/_main.md b/docs-source/forms-source/form1-doc/looping/_main.md new file mode 100644 index 0000000..f6addad --- /dev/null +++ b/docs-source/forms-source/form1-doc/looping/_main.md @@ -0,0 +1,10 @@ + + +Now it is time to use functions to examine looping and comparisons. + \ No newline at end of file diff --git a/docs-source/forms-source/form1-doc/looping.md b/docs-source/forms-source/form1-doc/looping/vectorsShorterThan.md similarity index 95% rename from docs-source/forms-source/form1-doc/looping.md rename to docs-source/forms-source/form1-doc/looping/vectorsShorterThan.md index d56a1b9..d07f350 100644 --- a/docs-source/forms-source/form1-doc/looping.md +++ b/docs-source/forms-source/form1-doc/looping/vectorsShorterThan.md @@ -1,13 +1,9 @@ -Now it is time to use functions to examine looping and comparisons. - -### Get Vectors Shorter Than ### - You will now create a function called `getVectorsShorterThan` that will take an array of arrays. It will compare each array based on its magnitude and return all arrays that have a magnitude smaller then the number provided. the signature will be: @@ -144,7 +140,7 @@ Add logic to handle 0, 1 or 2 vector cases -### It returns only vectors which are not too long #### +#### It returns only vectors which are not too long ### Modify the `getVectorsShorterThan` function so that it now returns only those vectors with a magnitude less then the length. diff --git a/docs/FIRST-FORM.md b/docs/FIRST-FORM.md index b7ec60a..c1159bb 100644 --- a/docs/FIRST-FORM.md +++ b/docs/FIRST-FORM.md @@ -1059,7 +1059,7 @@ Add logic to handle 0, 1 or 2 vector cases -### It returns only vectors which are not too long #### +#### It returns only vectors which are not too long ### Modify the `getVectorsShorterThan` function so that it now returns only those vectors with a magnitude less then the length. @@ -1115,6 +1115,7 @@ Move to general code for filtering vecctors (Is there a way you can use a known + ## The Other JS Learner Forms ## From 213a95a6c7c67b2171cab0ec4fa2a6aa245be939 Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 13:32:56 -0800 Subject: [PATCH 59/63] docs: removed old file --- docs-source/forms-source/why.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 docs-source/forms-source/why.md diff --git a/docs-source/forms-source/why.md b/docs-source/forms-source/why.md deleted file mode 100644 index e9c5a2c..0000000 --- a/docs-source/forms-source/why.md +++ /dev/null @@ -1,12 +0,0 @@ - - -There are two main reasons: - - \ No newline at end of file From a04d237eaae5a99479595aa6ae62b8220fa6c5fa Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 13:37:48 -0800 Subject: [PATCH 60/63] docs: updated spacing form2 --- docs-source/forms-source/form2-doc/buildVector.md | 1 + docs-source/forms-source/form2-doc/greeter.md | 3 ++- docs-source/forms-source/form2-doc/squareAll.md | 1 + docs-source/forms-source/form2-doc/sum.md | 1 + docs/SECOND-FORM.md | 5 ++++- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs-source/forms-source/form2-doc/buildVector.md b/docs-source/forms-source/form2-doc/buildVector.md index f6bad42..00d3317 100644 --- a/docs-source/forms-source/form2-doc/buildVector.md +++ b/docs-source/forms-source/form2-doc/buildVector.md @@ -3,6 +3,7 @@ (title "Build Vector") ) /bl--> + Now you will refactor the `buildVector` function changing its shape. ### Refactoring steps ### diff --git a/docs-source/forms-source/form2-doc/greeter.md b/docs-source/forms-source/form2-doc/greeter.md index c16e47b..eb5354b 100644 --- a/docs-source/forms-source/form2-doc/greeter.md +++ b/docs-source/forms-source/form2-doc/greeter.md @@ -3,6 +3,7 @@ (title "Greeter") ) /bl--> + Let us change the `greet` function. ### Refactoring steps ### @@ -81,4 +82,4 @@ The `typeof` operator returns a string with the name of the type. Maybe you can - + \ No newline at end of file diff --git a/docs-source/forms-source/form2-doc/squareAll.md b/docs-source/forms-source/form2-doc/squareAll.md index 9ce755c..e3987f1 100644 --- a/docs-source/forms-source/form2-doc/squareAll.md +++ b/docs-source/forms-source/form2-doc/squareAll.md @@ -3,6 +3,7 @@ (title "Square All") ) /bl--> + You will now refactor and change the shape of the `squareAll` method. ### Refactoring steps ### diff --git a/docs-source/forms-source/form2-doc/sum.md b/docs-source/forms-source/form2-doc/sum.md index 1c290d1..0cf1cc1 100644 --- a/docs-source/forms-source/form2-doc/sum.md +++ b/docs-source/forms-source/form2-doc/sum.md @@ -3,6 +3,7 @@ (title "Sum") ) /bl--> + You are going to refactor and change the shape of the `sum` method. ### Refactoring steps ### diff --git a/docs/SECOND-FORM.md b/docs/SECOND-FORM.md index 1a57c71..1f71049 100644 --- a/docs/SECOND-FORM.md +++ b/docs/SECOND-FORM.md @@ -20,6 +20,7 @@ You will be working in the [jsforms-source/2_second-form.js](../jsforms-source/2 - [Section 6: The Other JS Learner Forms](#user-content-the-other-js-learner-forms) ## Greeter ## + Let us change the `greet` function. ### Refactoring steps ### @@ -99,10 +100,10 @@ The `typeof` operator returns a string with the name of the type. Maybe you can - ## Sum ## + You are going to refactor and change the shape of the `sum` method. ### Refactoring steps ### @@ -209,6 +210,7 @@ An arrow function expression to log a value to the console looks like `value => ## Square All ## + You will now refactor and change the shape of the `squareAll` method. ### Refactoring steps ### @@ -292,6 +294,7 @@ Instead of an assignment, maybe just return the result of map. ## Build Vector ## + Now you will refactor the `buildVector` function changing its shape. ### Refactoring steps ### From a983d1eddbde537f8099686ce791f22deaac0b0a Mon Sep 17 00:00:00 2001 From: JasonEdf Date: Fri, 24 Feb 2023 13:39:08 -0800 Subject: [PATCH 61/63] docs: updated spacing form3 --- docs-source/forms-source/form3-doc/buildVector.md | 1 + docs-source/forms-source/form3-doc/greeter.md | 1 + docs-source/forms-source/form3-doc/sum.md | 1 + docs/THIRD-FORM.md | 3 +++ 4 files changed, 6 insertions(+) diff --git a/docs-source/forms-source/form3-doc/buildVector.md b/docs-source/forms-source/form3-doc/buildVector.md index a4662f0..1a43ac1 100644 --- a/docs-source/forms-source/form3-doc/buildVector.md +++ b/docs-source/forms-source/form3-doc/buildVector.md @@ -3,6 +3,7 @@ (title "Build Vector") ) /bl--> + You will refactor the `buildVector` function. ### Getter properties and value immutability ### diff --git a/docs-source/forms-source/form3-doc/greeter.md b/docs-source/forms-source/form3-doc/greeter.md index bd94d47..80382e6 100644 --- a/docs-source/forms-source/form3-doc/greeter.md +++ b/docs-source/forms-source/form3-doc/greeter.md @@ -3,6 +3,7 @@ (title "Greeter") ) /bl--> + You are going to start by refactoring the `greet` function. ### Refactoring steps ### diff --git a/docs-source/forms-source/form3-doc/sum.md b/docs-source/forms-source/form3-doc/sum.md index 6b6d69e..ef06cb5 100644 --- a/docs-source/forms-source/form3-doc/sum.md +++ b/docs-source/forms-source/form3-doc/sum.md @@ -3,6 +3,7 @@ (title "Sum") ) /bl--> + You will refactor the `sum` function. ### Refactoring steps ### diff --git a/docs/THIRD-FORM.md b/docs/THIRD-FORM.md index 3e52356..1aac781 100644 --- a/docs/THIRD-FORM.md +++ b/docs/THIRD-FORM.md @@ -18,6 +18,7 @@ You will be working in the [jsforms-source/3_third-form.js](../jsforms-source/3_ - [Section 4: The Other JS Learner Forms](#user-content-the-other-js-learner-forms) ## Greeter ## + You are going to start by refactoring the `greet` function. ### Refactoring steps ### @@ -131,6 +132,7 @@ The trinary operator has effectively moved to the `eitherOnType` method. The one ## Sum ## + You will refactor the `sum` function. ### Refactoring steps ### @@ -228,6 +230,7 @@ Get rid of the `result` variable and just return the result of the call to reduc ## Build Vector ## + You will refactor the `buildVector` function. ### Getter properties and value immutability ### From 092e398d5bfec1f522b63b38368f970d44de9e49 Mon Sep 17 00:00:00 2001 From: jason-kerney Date: Tue, 28 Feb 2023 07:35:29 -0800 Subject: [PATCH 62/63] fix: fixed reset files --- .reset-files/3_third-form.js | 1 + .reset-files/4_test-dummy-form.test.js | 36 ++++++++++++++------------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.reset-files/3_third-form.js b/.reset-files/3_third-form.js index 0aa7f65..637bee4 100644 --- a/.reset-files/3_third-form.js +++ b/.reset-files/3_third-form.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line const jsforms = (function () { 'use strict'; diff --git a/.reset-files/4_test-dummy-form.test.js b/.reset-files/4_test-dummy-form.test.js index 904eff2..beb48e9 100644 --- a/.reset-files/4_test-dummy-form.test.js +++ b/.reset-files/4_test-dummy-form.test.js @@ -29,22 +29,22 @@ describe('Test Dummy Form - Costume Shop Sales', function () { let salesReporter; beforeEach(function () { - pointOfSaleDataUtilsFactory = pointOfSaleDataUtilsFactoryBuilder(); + pointOfSaleDataUtilsFactory = pointOfSaleDataUtilityFactoryBuilder(); }); describe('Point of Sale Data Utilities', function () { - describe('get product count by sale', function () { - - let pointOfSaleDataUtilities; - let transactionStatuses; - let testData; - - beforeEach(function(){ - testData = buildSimpleTestData(); - transactionStatuses = buildTransactionStatuses(); - pointOfSaleDataUtilities = pointOfSaleDataUtilsFactory(transactionStatuses); - }); + // File being tested can be found here: + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/pointOfSaleDataUtilsFactory.js + + let pointOfSaleDataUtilities; + let transactionStatuses; + + beforeEach(function () { + transactionStatuses = buildTransactionStatuses(); + pointOfSaleDataUtilities = pointOfSaleDataUtilsFactory(transactionStatuses); + }); + describe('get product count by sale', function () { it('returns an empty object for sale counts if no sale data exists'); it('returns an object with a single count of 1 when only one item, quantity 1 was purchased'); @@ -64,7 +64,10 @@ describe('Test Dummy Form - Costume Shop Sales', function () { }); }); - describe('sales report', function () { + describe('get report', function () { + // files being tested are: + // ../jsforms-source/4_test-dummy-form/sales-reporter/salesReporterFactory.js + // ../jsforms-source/4_test-dummy-form/pos-transaction-services/reportDataBuilder.js describe('get sales report', function () { it('returns a report of sales with no sales'); @@ -76,10 +79,9 @@ describe('Test Dummy Form - Costume Shop Sales', function () { it('returns a report of sales excluding any return transactions'); }); - }); - describe('returns report', function () { - it('returns a report of return transactions that excludes sales transactions'); + describe('get returns report', function () { + it('returns a report of return transactions that excludes sales transactions'); + }); }); - }); From e6d00d5836d1418514efe13f5d9a19c7a8a6a7f0 Mon Sep 17 00:00:00 2001 From: jason-kerney Date: Tue, 28 Feb 2023 07:40:25 -0800 Subject: [PATCH 63/63] fix: restored comments from reset file --- .reset-files/6_async-test-dummy-form.test.js | 23 ++++++--- test/6_async-test-dummy-form.test.js | 51 ++++++++++++++++++-- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/.reset-files/6_async-test-dummy-form.test.js b/.reset-files/6_async-test-dummy-form.test.js index 5811b80..9968543 100644 --- a/.reset-files/6_async-test-dummy-form.test.js +++ b/.reset-files/6_async-test-dummy-form.test.js @@ -1,17 +1,27 @@ -/* global httpService, pluginApi, asyncContacts */ +/* +global + +asyncContacts, +chai, +httpService, +pluginApi +*/ 'use strict'; -describe('Test Dummy Form', function () { +describe('Async Test Dummy Form', function () { let contactService; + let responseData; beforeEach(function () { + responseData = {}; + const httpInstance = httpService(); const contactServiceInstance = contactService(httpInstance); const pluginApiInstance = pluginApi(); - - return asyncContacts(contactServiceInstance, pluginApiInstance); + + asyncContacts(contactServiceInstance, pluginApiInstance); }); // For this first suite of tests, we are going to work with comparing strings @@ -23,7 +33,7 @@ describe('Test Dummy Form', function () { it('should return 0 when two values are equal'); // Equality checking is one of the most common ways to test - // the results of code, so it's important to get comnfortable with it + // the results of code, so it's important to get comfortable with it it('should return -1 when name1 comes before name2 alphabetically'); // It's important to test all cases. The function, compareNames, has @@ -31,7 +41,6 @@ describe('Test Dummy Form', function () { // is to test until you're bored. Ideally, being bored will come at // about the same time you've tested all cases. it('should return 1 when name1 comes after name2 alphabetically'); - }); // Our second suite of tests will validate the behavior of a record comparison @@ -60,7 +69,6 @@ describe('Test Dummy Form', function () { // We could use the same record from the previous test to run this test case as well // If this generates duplicate code, how would we resolve that? it('should return 1 when last names are equal and record1.firstName comes after record3.firstName alphabetically'); - }); describe('sortByContactName', function () { @@ -75,7 +83,6 @@ describe('Test Dummy Form', function () { // sortByContactName always returns an array, so a calling function // doesn't fail on a type error it('should return an empty array if passed argument is not an array'); - }); describe('getContactNames', function () { diff --git a/test/6_async-test-dummy-form.test.js b/test/6_async-test-dummy-form.test.js index dec2fdf..9968543 100644 --- a/test/6_async-test-dummy-form.test.js +++ b/test/6_async-test-dummy-form.test.js @@ -24,46 +24,91 @@ describe('Async Test Dummy Form', function () { asyncContacts(contactServiceInstance, pluginApiInstance); }); + // For this first suite of tests, we are going to work with comparing strings + // The goal is to test that our string compare function works as expected describe('compareNames', function () { + // Checking if two values are equal can be done with assert.equal. + // Assert is part of the Chai testing package. it('should return 0 when two values are equal'); + // Equality checking is one of the most common ways to test + // the results of code, so it's important to get comfortable with it it('should return -1 when name1 comes before name2 alphabetically'); + // It's important to test all cases. The function, compareNames, has + // three distinct outcomes. One of the core ideas in testing your code + // is to test until you're bored. Ideally, being bored will come at + // about the same time you've tested all cases. it('should return 1 when name1 comes after name2 alphabetically'); - }); + // Our second suite of tests will validate the behavior of a record comparison + // function. We will need to create records which look like the following: + // { firstName: 'first name', lastName: 'last name' } describe('compareContactRecords', function () { + // Typically it's not necessary to test an extracted function, but it is useful to see + // tests written in small steps at times. Let's write some tests like we would + // normally do. it('should return 0 when first and last name are equal between two records'); + // Let's just get the next couple tests out of the way. They're like the first ones we wrote, + // but comparing records. it('should return -1 when record1.lastName comes before record2.lastName alphabetically'); + // After completing this test, we will have repeated code. Let's do this in two parts: + // - complete the test + // - lift the duplicated records into a beforeEach block it('should return 1 when record1.lastName comes after record2.lastName alphabetically'); + // We will need to introduce another record to test this next behavior. + // By reading the description, what does this new record need to contain? it('should return -1 when last names are equal and record1.firstName comes before record3.firstName alphabetically'); + // We could use the same record from the previous test to run this test case as well + // If this generates duplicate code, how would we resolve that? it('should return 1 when last names are equal and record1.firstName comes after record3.firstName alphabetically'); - }); describe('sortByContactName', function () { + // In this test we want to approve the output from the sort method. + // the verify method available globally. Try the following to see how + // to use it: + // console.log(exploreFunction(verify)); it('should return an array of records sorted by name'); + // We want to make sure that, even in the worst case scenario, + // sortByContactName always returns an array, so a calling function + // doesn't fail on a type error it('should return an empty array if passed argument is not an array'); - }); describe('getContactNames', function () { + // To fix this issue you will need to understand how the Mockery + // library works. The beforeEach at the very top of this test will + // give you a place to start. + // Assert has a method "doesNotThrow." This would be quite useful here it('should not throw error immediately when called'); + // Sinon is a library built for handling cases where you want to get a view + // of how functions are called within your tests. Let's spy on something and + // approve the results. it('should correctly request contact names from a remote service'); + // We will need to modify our setup a little more to ensure we + // get an error. It might be useful to know when an error occurs, + // promises typically call the reject method. + // - First get the test working + // - Second remove the asynchronicity from the test it('should call callback with error and a null value on failure'); + // Be careful with this one, approvals within promises produces some really + // strange output! This test will start almost the same as the error test. + // - First set promiseState.error to true, then see what happens + // - Add records to the promise state and verify on the full result it('should call callback with a null error and an array of sorted names on success'); });