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
public function closest_image_size( $width, $height, $photos ) { | |
foreach( $photos as $photo ) { | |
if( $width <= $photo['width'] && $height <= $photo['height'] ) { | |
$w = $photo['width'] - $width; | |
$h = $photo['height'] - $height; | |
if( !isset($source) ) { | |
$sum = $w + $h; | |
$source = $photo['source']; | |
} else if( $sum > ( $w + $h ) ) { | |
$sum = $w + $h; |
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 {addListItem} from '../index'; | |
describe('addListItem', () => { | |
beforeAll(() => { | |
document.body.innerHTML = '<ul id="unittest"></ul>'; | |
const $el = document.getElementById('unittest') | |
addListItem($el, 'First'); | |
addListItem($el, 'Second'); | |
addListItem($el, 'Third'); |
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 { isPositiveNumber } from '../index'; | |
describe('isPositiveNumber', () => { | |
test('Returns true if number is positive', () => { | |
expect(isPositiveNumber(5)).toBe(true); | |
}); | |
test('Returns false if number is negative', () => { | |
expect(isPositiveNumber(-5)).toBe(false); | |
}); |
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 { commaSeparatedStringToArray } from '../index'; | |
describe('commaSeparatedStringToArray', () => { | |
test('Returns array from comma separated string', () => { | |
expect(commaSeparatedStringToArray('my,unit,test')).toEqual(['my','unit','test']); | |
}); | |
test('Throws when non-string passed', () => { | |
expect(() => { | |
commaSeparatedStringToArray(5); |