Skip to content

Instantly share code, notes, and snippets.

View marcoemrich's full-sized avatar

Marco Emrich marcoemrich

View GitHub Profile
Download the React DevTools for a better development experience: http://fb.me/react-devtools /thirdparty/react.js:4356
Use brackets.getModule("thirdparty/CodeMirror2/lib/codemirror") instead of global CodeMirror.
at Object.defineProperty.get (/brackets.js:120:32)
at file:///home/memrich/.config/Brackets/extensions/user/brackets-livescript/main.js:8:7
at Object.<anonymous> (file:///home/memrich/.config/Brackets/extensions/user/brackets-livescript/main.js:253:7) /utils/DeprecationWarning.js:88
Use brackets.getModule("thirdparty/CodeMirror2/lib/codemirror") instead of global CodeMirror.
at Object.defineProperty.get (/brackets.js:120:32)
at Object.<anonymous> (file:///home/memrich/.config/Brackets/extensions/user/brackets-livescript/main.js:255:5) /utils/DeprecationWarning.js:88
Registering for deprecated event 'currentDocumentChange'. Instead, use MainViewManager.currentFileChange. Error
at Object.on (/utils/EventDispatcher.js:100:43)
@marcoemrich
marcoemrich / bling.js
Last active September 17, 2015 23:41 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@marcoemrich
marcoemrich / leap_year.spec.js
Last active July 3, 2020 14:28
JS-Testing: leap year specs
describe('leap year specs', () => {
describe('A year is a leap year if', () => {
it('is divisible by 4 but not by 100', () => {
expect(isLeapYear(2016)).toBeTruthy()
});
it('is divisible by 400', () => {
expect(isLeapYear(2000)).toBeTruthy()
});
});
@marcoemrich
marcoemrich / leap_year.param.spec.js
Last active July 3, 2020 14:28
JS-Testing: leap year parameterized spec
describe('leap year specs', () => {
describe('A year is a leap year if', () => {
it.each(
[2016, 1984, 4]
)(
'it is divisible by 4 but not by 100 (eg. %i)',
year => expect(isLeapYear(year)).toBeTruthy()
);
it.each(
[2400, 2000, 400]
@marcoemrich
marcoemrich / index.js
Last active July 3, 2020 14:36
JS-Testing: index
import React from "react";
import ReactDOM from "react-dom";
import TicTacToe from './model/tic_tac_toe'
import {Board} from './components/board'
const App = document.getElementById("app");
ReactDOM.render(<Board game={TicTacToe.startWithSize(3, 3)} />, App);
@marcoemrich
marcoemrich / assertions.spec.js
Last active July 3, 2020 14:29
JS-Testing: Assertion Examples
describe('greater than in obj', () => {
// is the second value of the obj greater than 5?
const obj = {value: [5, 4]};
// different Assertions/Expectations/Matcher Variants
it('jest equal', () => expect(obj.value[1] > 5).toBeTruthy());
it('jest greater', () => expect(obj.value[1]).toBeGreaterThan(5));
it('jest matchObject', () => expect(obj).toMatchObject({value: [5, 5]}));
it('unexpected satisfy', () =>
unexpect(obj, 'to satisfy', {value: [5, unexpect.it('to be greater than', 4)]})
@marcoemrich
marcoemrich / http.spec.js
Last active July 3, 2020 14:27
JS-Testing: Supertest example taken from README
describe('GET /user', function() {
it('responds with json', function(done) {
request(app)
.get('/user')
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200, done);
});
});
@marcoemrich
marcoemrich / ttt_enzyme.spec.js
Last active July 3, 2020 14:26
JS-Testing: Enzyme shallow rendering example
describe('Board', () => {
it('should have the right number of cells', () => {
const wrapper = shallow(<Board game={TicTacToe.startWithSize(4, 4)} />);
expect(wrapper.find(Cell).length).toEqual(16);
});
});
@marcoemrich
marcoemrich / ttt_testing_lib.spec.js
Last active July 3, 2020 14:26
JS-Testing: Testing Library testid example
it('should have the right number of cells', () => {
const { container, getAllByTestId } = render(<Board game={TicTacToe.startWithSize(4, 4)} />);
expect(
getAllByTestId("cell").length
).toEqual(16);
});
@marcoemrich
marcoemrich / some.spec.js
Last active July 3, 2020 14:26
JS-Testing: describe-it-structure
describe("...", () => {
it("...", () => {
...
})
});