Skip to content

Instantly share code, notes, and snippets.

View jimode's full-sized avatar
🎯
Focusing

Jimi Odeyemi jimode

🎯
Focusing
View GitHub Profile
// Object.values().filter(Boolean)
// -------------------------------
// Video: https://courses.wesbos.com/account/access/5f69bb13ebaa134ef228e80e/view/455624835
// Filter undefinded toppings out
const tops = Object.values(toppings).filter(topping => topping !== undefined)
// can also be written as:
const tops = Object.values(toppings).filter(Boolean)
// e.g Boolean(undefined) => will return false
// e.g Boolean(0) => will return false
@jimode
jimode / context-and-localstorage-using-hooks.js
Last active October 8, 2024 05:58
Providing Context and Local Storage Using Hooks
// Providing Context
// ==================
import React, {useState, useEffect} from "react"
const Context = React.createContext()
function ContextProvider({children}) {
const [allPhotos, setAllPhotos] = useState([])
const [cartItems, setCartItems] = useState([])
@jimode
jimode / index.html
Last active August 31, 2018 23:11
Shorthand for creating object literals - JS Bin// source https://jsbin.com/siqocem
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@jimode
jimode / index.html
Last active August 31, 2018 22:13
Introduction to Currying - JS Bin// source https://jsbin.com/dinahay
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@jimode
jimode / table-steps.js
Last active August 24, 2018 10:20
checking list of elements using tables
Then(/^I should see the following dropdown options$/, (table) => {
const expectedOptions = [].concat(...table.raw()); // this array is from the table in the scenario
const availableOptions = PaymentDetailsFormComponent.billingCountryOptions // this array will come from the collection of DOM elements
.map(option => option.getText());
expect(availableOptions).to.deep.eq(expectedOptions);
});
@jimode
jimode / browserSroll.js
Last active July 25, 2018 13:31
Get location co-ordinates of elements and get browser to scroll to it.
// Webdriver.IO
const [x, y] = Object.values(this.cardPaymentOption.getLocation());
browser.scroll(x, y);
this.cardPaymentOption.click();
const [x1, y1] = Object.values(this.ccSecureCheckoutText.getLocation());
browser.scroll(x1, y1);
this.ccSecureCheckoutText.waitForVisible();
When(/^there is no hover border displayed$/, () => {
const monthlySubscription =
SelectSubscription.monthly.plan.selector;
function getPsuedoAttributeValues(component, selector, cssProperty) {
return window
.getComputedStyle(document.querySelector(component), selector)
.getPropertyValue(cssProperty);
}
@jimode
jimode / JUnit: Print_hybrid_driver2.java
Created May 22, 2014 13:01
JUnit: hyrbrid_framework
// Global Variables
public class hybrid_driver1 {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
//Test Case Variables
int xRows_TC, xCols_TC;
String[][] xData_TC;
@jimode
jimode / gist:5569097
Created May 13, 2013 15:19
JUnit: HSSF Workbook
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.junit.After;
@jimode
jimode / gist:5569053
Created May 13, 2013 15:13
JUnit: IE Driver
// Run test in Internet Explorer
File file =new File("C:/Users/Jimi/Selenium/Workspace/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver myD = new InternetExplorerDriver();