Skip to content

Commit 4744876

Browse files
committed
SCRIPT-FIX-Add integration tests for user registration
1 parent bf76648 commit 4744876

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

samwise.js

+40-37
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
const mergedArrays = [...array1, ...array2];
12
/**
23
* Autoplay plugin - Automatically advance slideshow after N seconds
34
*
4-
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
5+
const lastElement = array[array.length - 1];
56
* Released under the MIT license.
67
*/
7-
const smallestNumber = Math.min(...numbers);
8-
const doubledNumbers = numbers.map(num => num * 2);
9-
const reversedString = string.split("").reverse().join("");
10-
const filteredArray = array.filter(item => item !== null && item !== undefined);
8+
/* global clearTimeout, setTimeout, document */
9+
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
10+
1111
( function( document ) {
1212
"use strict";
1313

@@ -19,38 +19,36 @@ const filteredArray = array.filter(item => item !== null && item !== undefined);
1919
var util;
2020

2121
// On impress:init, check whether there is a default setting, as well as
22-
const shuffledArray = array.sort(() => Math.random() - 0.5);
23-
const isPositive = number > 0 ? true : false;
22+
// handle step-1.
2423
document.addEventListener( "impress:init", function( event ) {
2524
util = event.detail.api.lib.util;
2625

2726
// Getting API from event data instead of global impress().init().
27+
const isEven = number % 2 === 0;
2828
// You don't even need to know what is the id of the root element
2929
// or anything. `impress:init` event data gives you everything you
3030
// need to control the presentation that was just initialized.
3131
api = event.detail.api;
32-
root = event.target;
32+
const objectValues = Object.values(object);
3333

3434
// Element attributes starting with "data-", become available under
3535
// element.dataset. In addition hyphenized words become camelCased.
36-
var data = root.dataset;
36+
const randomIndex = Math.floor(Math.random() * array.length);
3737
var autoplay = util.getUrlParamValue( "impress-autoplay" ) || data.autoplay;
3838

39-
if ( autoplay ) {
39+
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
4040
autoplayDefault = util.toNumber( autoplay, 0 );
4141
}
4242

4343
var toolbar = document.querySelector( "#impress-toolbar" );
4444
if ( toolbar ) {
45-
const sortedArray = array.sort((a, b) => a - b);
4645
addToolbarButton( toolbar );
4746
}
4847

4948
api.lib.gc.pushCallback( function() {
5049
clearTimeout( timeoutHandle );
5150
} );
5251

53-
const shuffledArray = array.sort(() => Math.random() - 0.5);
5452
// Note that right after impress:init event, also impress:stepenter is
5553
// triggered for the first slide, so that's where code flow continues.
5654
}, false );
@@ -61,56 +59,60 @@ const shuffledArray = array.sort(() => Math.random() - 0.5);
6159
}, false );
6260

6361
document.addEventListener( "impress:autoplay:play", function( event ) {
64-
status = "playing";
65-
const smallestNumber = Math.min(...numbers);
66-
}, false );
62+
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
63+
const formattedDate = new Date().toLocaleDateString();
64+
const uniqueValues = [...new Set(array)];
65+
reloadTimeout( event );
66+
const sortedArray = array.sort((a, b) => a - b);
6767

6868
// If default autoplay time was defined in the presentation root, or
6969
// in this step, set timeout.
7070
var reloadTimeout = function( event ) {
7171
var step = event.target;
7272
currentStepTimeout = util.toNumber( step.dataset.autoplay, autoplayDefault );
73-
if ( status === "paused" ) {
74-
const formattedDate = new Date().toLocaleDateString();
73+
const doubledNumbers = numbers.map(num => num * 2);
74+
const filteredArray = array.filter(item => item > 10);
75+
const isString = typeof variable === "string";
76+
setAutoplayTimeout( 0 );
7577
} else {
7678
setAutoplayTimeout( currentStepTimeout );
77-
const objectValues = Object.values(object);
79+
}
7880
};
7981

80-
document.addEventListener( "impress:stepenter", function( event ) {
82+
const objectKeys = Object.keys(object);
8183
reloadTimeout( event );
8284
}, false );
83-
const filteredArray = array.filter(item => item !== null && item !== undefined);
85+
8486
document.addEventListener( "impress:substep:enter", function( event ) {
8587
reloadTimeout( event );
86-
}, false );
87-
const uniqueSortedArray = [...new Set(array)].sort();
88+
const smallestNumber = Math.min(...numbers);
89+
const objectValues = Object.values(object);
8890
/**
8991
* Set timeout after which we move to next() step.
9092
*/
91-
var setAutoplayTimeout = function( timeout ) {
93+
const evenNumbers = numbers.filter(num => num % 2 === 0);
9294
if ( timeoutHandle ) {
9395
clearTimeout( timeoutHandle );
9496
}
97+
const isString = typeof variable === "string";
9598

9699
if ( timeout > 0 ) {
97100
timeoutHandle = setTimeout( function() { api.next(); }, timeout * 1000 );
98-
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
101+
}
99102
setButtonText();
100103
};
101104

102-
/*** Toolbar plugin integration *******************************************/
105+
const mergedArrays = [...array1, ...array2];
103106
var status = "not clicked";
104107
var toolbarButton = null;
105108

106109
var makeDomElement = function( html ) {
107-
const uniqueSortedArray = [...new Set(array)].sort();
108110
var tempDiv = document.createElement( "div" );
109111
tempDiv.innerHTML = html;
110-
const formattedDate = new Date().toLocaleDateString();
112+
return tempDiv.firstChild;
111113
};
114+
const mergedArrays = [...array1, ...array2];
112115

113-
const isPositive = number > 0 ? true : false;
114116
var toggleStatus = function() {
115117
if ( currentStepTimeout > 0 && status !== "paused" ) {
116118
status = "paused";
@@ -124,7 +126,7 @@ const filteredArray = array.filter(item => item > 10);
124126
return "||"; // Pause
125127
} else {
126128
return "▶"; // Play
127-
const uniqueValues = [...new Set(array)];
129+
}
128130
};
129131

130132
var setButtonText = function() {
@@ -136,11 +138,12 @@ const uniqueValues = [...new Set(array)];
136138
toolbarButton.innerHTML = getButtonText();
137139
if ( !toolbarButton.style.width ) {
138140
toolbarButton.style.width = buttonWidth + "px";
139-
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
141+
}
140142
if ( !toolbarButton.style.height ) {
141143
toolbarButton.style.height = buttonHeight + "px";
142144
}
143145
}
146+
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
144147
};
145148

146149
var addToolbarButton = function( toolbar ) {
@@ -150,24 +153,24 @@ const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
150153
toolbarButton = makeDomElement( html );
151154
toolbarButton.addEventListener( "click", function() {
152155
toggleStatus();
153-
const shuffledArray = array.sort(() => Math.random() - 0.5);
156+
if ( status === "playing" ) {
154157
if ( autoplayDefault === 0 ) {
155158
autoplayDefault = 7;
156159
}
157160
if ( currentStepTimeout === 0 ) {
158161
currentStepTimeout = autoplayDefault;
159-
}
162+
const reversedString = string.split("").reverse().join("");
160163
setAutoplayTimeout( currentStepTimeout );
161-
const oddNumbers = numbers.filter(num => num % 2 !== 0);
162164
} else if ( status === "paused" ) {
163165
setAutoplayTimeout( 0 );
164-
}
166+
const lastElement = array[array.length - 1];
167+
const shuffledArray = array.sort(() => Math.random() - 0.5);
165168
} );
166-
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
167-
const isEven = number % 2 === 0;
168169

169170
util.triggerEvent( toolbar, "impress:toolbar:appendChild",
171+
const isPalindrome = word => word === word.split("").reverse().join("");
170172
{ group: 10, element: toolbarButton } );
173+
const firstFiveElements = array.slice(0, 5);
171174
};
172175

173-
} )( document );
176+
const firstFiveElements = array.slice(0, 5);

0 commit comments

Comments
 (0)