Fix JS for tests

This commit is contained in:
Clement Ho 2016-11-09 19:10:15 -06:00
parent 6fb47427c7
commit 8b4e4e333d
2 changed files with 5 additions and 4 deletions

View file

@ -50,7 +50,7 @@
// Sanitize value since URL converts spaces into + // Sanitize value since URL converts spaces into +
// Replace before decode so that we know what was originally + versus the encoded + // Replace before decode so that we know what was originally + versus the encoded +
const sanitizedValue = value ? decodeURIComponent(value.replace(/[+]/g, ' ')) : value; const sanitizedValue = value ? decodeURIComponent(value.replace(/[+]/g, ' ')) : value;
const match = validTokenKeys.find(t => key === `${t.key}_${t.param}`); const match = validTokenKeys.filter(t => key === `${t.key}_${t.param}`)[0];
if (match) { if (match) {
const sanitizedKey = key.slice(0, key.indexOf('_')); const sanitizedKey = key.slice(0, key.indexOf('_'));
@ -103,7 +103,8 @@
} }
checkForEnter(event) { checkForEnter(event) {
if (event.key === 'Enter') { // Enter KeyCode
if (event.keyCode === 13) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
this.search(); this.search();
@ -132,7 +133,7 @@
path += `&state=${currentState}`; path += `&state=${currentState}`;
tokens.forEach((token) => { tokens.forEach((token) => {
const param = validTokenKeys.find(t => t.key === token.key).param; const param = validTokenKeys.filter(t => t.key === token.key)[0].param;
path += `&${token.key}_${param}=${encodeURIComponent(token.value)}`; path += `&${token.key}_${param}=${encodeURIComponent(token.value)}`;
}); });

View file

@ -57,7 +57,7 @@
if (colonIndex !== -1) { if (colonIndex !== -1) {
const tokenKey = i.slice(0, colonIndex).toLowerCase(); const tokenKey = i.slice(0, colonIndex).toLowerCase();
const tokenValue = i.slice(colonIndex + 1); const tokenValue = i.slice(colonIndex + 1);
const match = this.validTokenKeys.find(v => v.key === tokenKey); const match = this.validTokenKeys.filter(v => v.key === tokenKey)[0];
if (tokenValue.indexOf('"') !== -1) { if (tokenValue.indexOf('"') !== -1) {
lastQuotation = '"'; lastQuotation = '"';