Skip to content

Instantly share code, notes, and snippets.

@aledoroshenko
Last active October 24, 2016 08:57
Show Gist options
  • Save aledoroshenko/41b36c78d52e9293b1ca9c911c6cf3e3 to your computer and use it in GitHub Desktop.
Save aledoroshenko/41b36c78d52e9293b1ca9c911c6cf3e3 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
<div class="ncc-grid-block secondary-nac-block jstest1"></div>
<div class="ncc-grid-block secondary-nac-block jstest2"></div>
<div class="jstest3"></div>
</body>
</html>
import $ from 'jquery';
import expect from 'expect';
import _ from 'lodash';
function needForceClear(element) {
var $element = $(element);
return _.some(_.map(
['ncc-grid-block', 'secondary-nav-block', 'customer-header']),
$element.hasClass.bind($element)
)
}
tests();
function tests() {
var el1 = $('.jstest1').get(0);
var el2 = $('.jstest2');
var el3 = $('.jstest3');
expect(needForceClear(el1)).toBe(true);
expect(needForceClear(el2)).toBe(true);
expect(needForceClear(el3)).toBe(false);
expect(needForceClear(undefined)).toBe(false);
console.log('tests success')
}
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependecies": {
"lodash": "~4.14.1",
"expect": "~1.20.2",
"jquery": "~3.1.1"
},
"dependencies": {
"jquery": "3.1.1",
"expect": "1.20.2",
"lodash": "4.16.2"
}
}
'use strict';
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
var _expect = require('expect');
var _expect2 = _interopRequireDefault(_expect);
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function needForceClear(element) {
var $element = (0, _jquery2.default)(element);
return _lodash2.default.some(_lodash2.default.map(['ncc-grid-block', 'secondary-nav-block', 'customer-header']), $element.hasClass.bind($element));
}
tests();
function tests() {
var el1 = (0, _jquery2.default)('.jstest1').get(0);
var el2 = (0, _jquery2.default)('.jstest2');
var el3 = (0, _jquery2.default)('.jstest3');
(0, _expect2.default)(needForceClear(el1)).toBe(true);
(0, _expect2.default)(needForceClear(el2)).toBe(true);
(0, _expect2.default)(needForceClear(el3)).toBe(false);
(0, _expect2.default)(needForceClear(undefined)).toBe(false);
console.log('tests success');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment