Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#158 a single continue button #181

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ));
}
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 8 additions & 9 deletions tests/unit_tests/getMatchingRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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 other mutiple choice continue 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 );

Expand All @@ -52,7 +52,6 @@ it("matches the right table and field rows for other mutiple choice continue but

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 );

});


Expand Down
8 changes: 8 additions & 0 deletions tests/unit_tests/getPageData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
});
Expand Down
28 changes: 27 additions & 1 deletion tests/unit_tests/html.fixtures.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion tests/unit_tests/matches.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ matches.show_if = [
// ============================
// Buttons
// ============================
// `continue button field:`
matches.button_continue = [
{
"field": { "selector": "button[name=\"YnV0dG9uX2NvbnRpbnVl\"][value=\"True\"]", "tag": "button", "rows": [ { "var_name": "button_continue", "value": "True", "checked": false } ], "type": "submit" },
"table": { "var_name": "button_continue", "value": "True", "checked": true, },
}
];

// `yesnomaybe:`
matches.buttons_yesnomaybe_yes = [
{
"field": { "selector": "button[name=\"YnV0dG9uc195ZXNub21heWJl\"][value=\"True\"]", "tag": "button", "rows": [ { "var_name": "buttons_yesnomaybe", "value": "True", "checked": false, } ], "type": "submit" },
Expand All @@ -146,7 +155,7 @@ matches.buttons_yesnomaybe_none = [
}
];


// `field:` and `buttons:`
matches.buttons_other_1 = [
{
"field": { "selector": "button[name=\"YnV0dG9uc19vdGhlcg\"][value=\"button_1\"]", "tag": "button", "rows": [ { "var_name": "buttons_other", "value": "button_1", "checked": false, } ], "type": "submit" },
Expand Down
23 changes: 23 additions & 0 deletions tests/unit_tests/page_data.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ page_data.show_if = {
// ============================
// Buttons
// ============================
// `continue button field:`
page_data.button_continue = {
"sought_var": [
"button_continue"
],
"fields": [
{
"selector": "button[name=\"YnV0dG9uX2NvbnRpbnVl\"][value=\"True\"]",
"tag": "button",
"rows": [
{
"var_name": "button_continue",
"value": "True",
"checked": false
}
],
"type": "submit"
}
]
};

// `yesnomaybe:`
// TODO: Shall we allow 'maybe' in the table as a value for `None`?
page_data.buttons_yesnomaybe = {
"sought_var": [
Expand Down Expand Up @@ -430,6 +452,7 @@ page_data.buttons_yesnomaybe = {
};

// Multiple choice 'continue' button fields that are not yesnomaybe
// `field:` and `buttons:`
page_data.buttons_other = {
"sought_var": [
"buttons_other"
Expand Down
7 changes: 7 additions & 0 deletions tests/unit_tests/tables.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ tables.show_if = [
// ============================
// Buttons
// ============================
// `continue button field:`
tables.button_continue = [
{ "var_name": "button_continue", "value": "True", "checked": true, }, // May want to change `checked`
];

// `yesnomaybe:`
tables.buttons_yesnomaybe_yes = [
{ "var_name": "buttons_yesnomaybe", "value": "True", "checked": true, }, // May want to change `checked`
];
Expand All @@ -59,6 +65,7 @@ tables.buttons_yesnomaybe_none = [
{ "var_name": "buttons_yesnomaybe", "value": "None", "checked": true, }, // May want to change `checked`
];

// `field:` and `buttons:`
tables.buttons_other_1 = [
{ "var_name": "buttons_other", "value": "button_1", "checked": true, }, // May want to change `checked`
];
Expand Down