This file contains 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
var getWindow = require( './window' ).getWindow; | |
function getSomethingFromTheDOM() { | |
return getWindow().document.querySelector( '.something' ); | |
} |
This file contains 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
// Set up DOM | |
var jsdom = require( 'jsdom' ).jsdom; | |
global.document = jsdom( '' ); | |
global.window = document.defaultView; | |
global.navigator = document.defaultView.navigator; | |
// Prepare React | |
var ReactTestUtils = require( 'react-addons-test-utils' ); | |
var React = require( 'react' ); |
This file contains 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
<?php | |
class GreetingGenerator { | |
public function get_greeting( $name ) { | |
// Assumes determine_greeting is defined in another file | |
return determine_greeting( $name ); | |
} | |
} | |
class Greeter { |
This file contains 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
<?php | |
use PHPUnit\Framework\TestCase; | |
class MyTime { | |
/** | |
* Convert a float string timezone offset to a DateTimeZone | |
* | |
* @param string $number The initial offset float, as a string. | |
* @return DateTimeZone The converted DateTimeZone | |
*/ |
This file contains 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
"use strict" | |
class OriginalObj { | |
sayHello() { | |
console.log( 'hello' ); | |
} | |
} | |
const myOriginal = new OriginalObj(); | |
myOriginal.sayHello(); |
This file contains 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
module.exports = function( babel ) { | |
const t = babel.types; | |
let insertedPhp = false; | |
const updateParamNameVisitor = { | |
Identifier( path ) { | |
if ( path.node.name.startsWith( '$' ) ) { | |
return; | |
} | |
// Transform VariableDeclarator Identifiers to PHP style |
This file contains 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
window.registerBlock('My Block', function() { return '<p>this is my block</p>' }) |
This file contains 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
/* globals describe, it */ | |
import React from 'react'; | |
import { expect } from 'chai'; | |
// Using React.createElement works too! | |
import { renderToString, createElement } from './renderer'; | |
describe( 'renderToString()', function() { | |
it( 'returns a string with a tag wrapping plain text for a component with one text child', function() { |
This file contains 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 React from 'react'; | |
export function Header( { title, subtitle, className } ) { | |
return ( | |
<div className={ className }> | |
<h1>{ title }</h1> | |
<span>{ subtitle }</span> | |
</div> | |
); | |
} |
This file contains 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
<?php | |
$autoload = 'vendor/autoload.php'; | |
$patchwork = 'vendor/antecedent/patchwork/Patchwork.php'; | |
# require patchwork first | |
if ( file_exists( $patchwork ) ) { | |
require_once $patchwork; | |
} | |
if ( file_exists( $autoload ) ) { |