This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mock default constructor | |
import SomeConstructor from "some-package" | |
const SomePackageMock = { | |
default: jest.fn(), | |
} | |
jest.mock("some-package", () => SomePackageMock) | |
// Import place where construcor from some-package is used | |
import { testStuff } from "../Scroll/useElementSize" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { ControlType, PropertyControls, Size } from 'framer'; | |
interface Props extends Size { | |
images: string[]; | |
} | |
interface State { | |
index: number; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { PropertyControls, ControlType } from "framer"; | |
import { FontWeightProperty, TextAlignProperty } from "csstype"; | |
type FontWeight = | |
| "normal" | |
| "bold" | |
| "lighter" | |
| "bolder" | |
| "100" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Could be served via CRA with default port 3000 | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { num: 0 }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import { PropertyControls, ControlType } from 'framer'; | |
import { data } from './Examples'; | |
// Define type of property | |
interface Props { | |
text: string; | |
} | |
export class Display extends React.Component<Props> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function walkTree(onEachChildren, childrenKey = "children") { | |
return function treeWalker(elem, level = 0) { | |
onEachChildren(elem, level); | |
if (elem[childrenKey]) { | |
elem[childrenKey].forEach(item => treeWalker(item, level + 1)); | |
} | |
}; | |
} | |
// how to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function fromPromise(promise) { | |
return new Observable(observer => { | |
let active = true; | |
promise.then((...data) => { | |
if (active) { | |
observer.next(...data); | |
} | |
observer.complete(); | |
}).catch((...err) => observer.error(...err)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// return resolved promise | |
sandbox.stub(Obj, 'method').resolves(value); | |
// return rejected promise | |
sandbox.stub(Obj, 'method').rejects(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
function debounce(callback, delay) { | |
var timeout; | |
return function() { | |
var context = this, | |
args = arguments; |