Skip to content

Instantly share code, notes, and snippets.

View niinpatel's full-sized avatar
💭
goofing off

Nitin Patel niinpatel

💭
goofing off
View GitHub Profile
breakingRecords :: [Int] -> [Int]
updateMinMax [maxRec,minRec,max, min] score =
[newMaxRec,newMinRec,newMax,newMin]
where
newMax = if score > max then score else max
newMin = if score < min then score else min
newMaxRec = if newMax > max then (maxRec + 1) else maxRec
newMinRec = if newMin < min then (minRec + 1) else minRec
test('should update the value when onChange is called', () => {
act(() => {
nameField.onChange({ target: { value: 'nitin' } });
});
expect(nameField.value).toBe('nitin');
});
test('should update the value when onChange is called', () => {
nameField.onChange({ target: { value: 'nitin' } });
expect(nameField.value).toBe('nitin');
});
import useCustomEffect from '../useCustomEffect';
import testHook from '../testHook';
import sideEffect from 'sideeffect';
jest.mock('sideeffect')
describe('useCustomEffect', () => {
test('should call side effect', () => {
testHook(useCustomEffect);
expect(sideEffect).toHaveBeenCalledTimes(1);
import { act } from 'react-dom/test-utils';
import { testHook } from './testUtils';
import useTextField from '../useTextField';
let nameField;
beforeEach(() => {
testHook(() => {
nameField = useTextField('name');
});
});
import React from 'react';
import { mount } from 'enzyme';
const TestHook = ({ callback }) => {
callback();
return null;
};
export const testHook = (callback) => {
mount(<TestHook callback={callback} />);
import React, { useState } from 'react';
const useTextField = name => {
const [value, setValue] = useState('');
const onChange = event => {
setValue(event.target.value);
};
return {
import React, { Component } from 'react';
export default class InputDemo extends Component {
state = {
name: '',
};
handleChange = event => {
this.setState({
[event.target.name]: event.target.value,
like = document.getElementsByClassName('recsGamepad__button--like')[0]
dislike = document.getElementsByClassName('recsGamepad__button--dislike')[0]
setInterval(() => {
randomNo = Math.random()
if (randomNo <= .50) // to like 50% of profiles, change this number to change the like/dislike ratio.
like.click()
else
import React, { Component } from 'react';
import './App.css';
import ResultComponent from './components/ResultComponent';
import KeyPadComponent from "./components/KeyPadComponent";
class App extends Component {
constructor(){
super();
this.state = {