From 2f1767ba528996e9c10a92c73dd677ace4d9866f Mon Sep 17 00:00:00 2001
From: plocket <52798256+plocket@users.noreply.github.com>
Date: Tue, 23 Mar 2021 14:29:09 -0400
Subject: [PATCH] Add and test one continue button `continue_button_field:`
---
lib/scope.js | 4 ++--
tests/unit_tests/getMatchingRow.test.js | 17 +++++++--------
tests/unit_tests/getPageData.test.js | 8 +++++++
tests/unit_tests/html.fixtures.js | 28 ++++++++++++++++++++++++-
tests/unit_tests/matches.fixtures.js | 11 +++++++++-
tests/unit_tests/page_data.fixtures.js | 23 ++++++++++++++++++++
tests/unit_tests/tables.fixtures.js | 7 +++++++
7 files changed, 85 insertions(+), 13 deletions(-)
diff --git a/lib/scope.js b/lib/scope.js
index 3fda90bc..07cea98d 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -621,7 +621,7 @@ module.exports = {
} // ends for every node
- if ( page_data.sought_var[0] === `buttons_other`) {
+ if ( page_data.sought_var[0] === `button_continue`) {
// console.log( field_like_names );
// console.log( JSON.stringify( page_data, null, 2 ));
}
@@ -891,7 +891,7 @@ module.exports = {
} // ends for each field row possibility
} // ends for each field
- if ( page_data.sought_var[0] === `buttons_other`) {
+ if ( page_data.sought_var[0] === `button_continue`) {
// console.log( JSON.stringify( matches, null, 2 ));
}
return matches;
diff --git a/tests/unit_tests/getMatchingRow.test.js b/tests/unit_tests/getMatchingRow.test.js
index 5aa187d8..23752b08 100644
--- a/tests/unit_tests/getMatchingRow.test.js
+++ b/tests/unit_tests/getMatchingRow.test.js
@@ -14,22 +14,24 @@ const getMatchingRow = scope.getMatchingRow;
// ============================
// TODO: Add more complex fields. E.g `object_checkboxes` and dropdown with `object`.
it("matches the right table and field rows for standard fields", async function() {
-
let result = await getMatchingRow( scope, { page_data: page_data.standard, story_table: tables.standard });
expect( result ).to.deep.equal( matches.standard );
-
});
it("matches the right table and field rows for simple show if fields", async function() {
-
let result = await getMatchingRow( scope, { page_data: page_data.show_if, story_table: tables.show_if });
expect( result ).to.deep.equal( matches.show_if );
-
});
+// `continue button field:`
+it(`creates the right data for one continue button`, async function() {
+ // `continue button field:`
+ let result1 = await getMatchingRow( scope, { page_data: page_data.button_continue, story_table: tables.button_continue });
+ expect( result1 ).to.deep.equal( matches.button_continue );
+});
+// `yesnomaybe:`
it("matches the right table and field rows for yesnomaybe buttons", async function() {
-
let result1 = await getMatchingRow( scope, { page_data: page_data.buttons_yesnomaybe, story_table: tables.buttons_yesnomaybe_yes });
expect( result1 ).to.deep.equal( matches.buttons_yesnomaybe_yes );
@@ -38,12 +40,10 @@ it("matches the right table and field rows for yesnomaybe buttons", async functi
let result3 = await getMatchingRow( scope, { page_data: page_data.buttons_yesnomaybe, story_table: tables.buttons_yesnomaybe_none });
expect( result3 ).to.deep.equal( matches.buttons_yesnomaybe_none );
-
});
-
+// `field:` and `buttons:`
it("matches the right table and field rows for yesnomaybe buttons", async function() {
-
let result1 = await getMatchingRow( scope, { page_data: page_data.buttons_other, story_table: tables.buttons_other_1 });
expect( result1 ).to.deep.equal( matches.buttons_other_1 );
@@ -52,7 +52,6 @@ it("matches the right table and field rows for yesnomaybe buttons", async functi
let result3 = await getMatchingRow( scope, { page_data: page_data.buttons_other, story_table: tables.buttons_other_3 });
expect( result3 ).to.deep.equal( matches.buttons_other_3 );
-
});
diff --git a/tests/unit_tests/getPageData.test.js b/tests/unit_tests/getPageData.test.js
index d38d3733..76d0b5f0 100644
--- a/tests/unit_tests/getPageData.test.js
+++ b/tests/unit_tests/getPageData.test.js
@@ -34,12 +34,20 @@ it(`creates the right data for 'show if' fields`, async function() {
expect( result ).to.deep.equal( page_data.show_if );
});
+it(`creates the right data for one continue button`, async function() {
+ // `continue button field:`
+ let result = await getPageData( scope, { html: html.button_continue });
+ expect( result ).to.deep.equal( page_data.button_continue );
+});
+
it(`creates the right data for yesnomaybe buttons`, async function() {
+ // `yesnomaybe:`
let result = await getPageData( scope, { html: html.buttons_yesnomaybe });
expect( result ).to.deep.equal( page_data.buttons_yesnomaybe );
});
it(`creates the right data for other mutiple choice continue buttons`, async function() {
+ // `field:` and `buttons:`
let result = await getPageData( scope, { html: html.buttons_other });
// expect( result ).to.deep.equal( page_data.buttons_other );
});
diff --git a/tests/unit_tests/html.fixtures.js b/tests/unit_tests/html.fixtures.js
index a9505386..57ab804f 100644
--- a/tests/unit_tests/html.fixtures.js
+++ b/tests/unit_tests/html.fixtures.js
@@ -326,6 +326,31 @@ html.show_if = `
// ============================
// Buttons
// ============================
+// `continue button field:`
+html.button_continue = `
+`;
+
+// `yesnomaybe:`
html.buttons_yesnomaybe = `
`;
// Multiple choice 'continue' button fields that are not yesnomaybe
+// `field:` and `buttons:`
html.buttons_other = `