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
| console.log(1..toString()); |
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
| var people = (function() { | |
| var people = []; | |
| render(); | |
| function render() { | |
| var people = people; | |
| console.log(people); | |
| } | |
| }()) |
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 { combineReducers } from 'redux'; | |
| import { LOGIN, LOGOUT } from './action-types'; | |
| const initialState = {}; | |
| const user = (state = initialState, action) => { | |
| const actionTypeHandlerMap = { | |
| [LOGIN]: ({ status, userInfo }) => ({ ...state, status, userInfo }), | |
| [LOGOUT]: ({ status }) => ({ ...state, status, userInfo: {}}), | |
| [undefined]: () => state | |
| } |
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 $ from 'jquery'; | |
| export const isEmpty = value => !value.length; | |
| export default function getValidator(rule, inputSelector, valueGetter) { | |
| return { | |
| validate() { | |
| const $input = $(inputSelector); | |
| const value = valueGetter(); |
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 { assert } from 'chai'; | |
| import proxyquire from 'proxyquire'; | |
| import { getJquerySpies, getJquery } from '../src/jquery-getter'; | |
| const $ = getJquery(); | |
| const getValidator = proxyquire('../src/validator', { jquery : $ }).default; | |
| const isEmpty = proxyquire('../src/validator', { jquery : $ }).isEmpty; | |
| const addClassFn = getJquerySpies().addClass; |
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
| const sinon = require('sinon'); | |
| const fakeDOM = require('jsdom').jsdom(); | |
| let nodeJquery = null; | |
| let jquerySpies = null; | |
| export function getJquery() { | |
| if (!nodeJquery) { | |
| nodeJquery = require('jquery')(fakeDOM.defaultView); | |
| } |
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 { View } from 'backbone'; | |
| import { getJquery }from './jquery-getter'; | |
| const $ = getJquery(); | |
| export class SimpleView extends View { | |
| constroctor() { | |
| super({ el: '#someDiv' }); | |
| } | |
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
| const fakeDOM = require(‘jsdom’).jsdom(); | |
| nodeJquery = require(‘jquery’)(fakeDom.defaultView); |
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
| let nodeJquery = null; | |
| export function getJquery(spy = false) { | |
| if (!nodeJquery) { | |
| const sinon = require('sinon'); | |
| const fakeDOM = require('jsdom').jsdom(); | |
| nodeJquery = require('jquery')(fakeDOM.defaultView); | |
| } | |
| return nodeJquery; |