Skip to content

Instantly share code, notes, and snippets.

View javierfernandes's full-sized avatar

Javier Fernandes javierfernandes

  • Buenos Aires, Argentina
View GitHub Profile
const A = { id: 'A', name: 'A' }
const B = { id: 'B', name: 'B' }
const NEW = { id: 'NEW', sys: 'marker', data: { children: [] }, project: 'my-project' }
it('should add a new object for a single ADDED change', () => {
doTest({
objects: { A, B },
changes: [
{ added: NEW }
],
it('should add a new object for a single ADDED change', () => {
doTest({
objects: {
A: { id: 'A', name: 'A' },
B: { id: 'B', name: 'B' },
},
changes: [
{ added: { id: 'NEW', sys: 'marker', data: { children: [] }, project: 'my-project' } }
],
expectedObjects: (objects, changes) => ({
const author = { sessionId: 'my_session', user: { _id: 'JOHN' } }
const UNDO = (_id, index = 0, timestamp) => ({ _id: `-${_id}-${index}`, author, reverts: { _id }, timestamp })
const REDO = (_id, index = 0, timestamp) => ({ _id: `+${_id}-${index}`, author, reapplies: { _id }, timestamp })
const change = (_id, timestamp) => ({ _id, author, timestamp })
const parseArray = elementParser => pipe(
drop(1), dropLast(1), // [ ... ]
trim,
split(','),
const expectIsWithin = text => {
const { state, entityMatch } = createStateAndEntityMatch(text)
return expect(isWithinEntityMatch(state, entityMatch))
}
export const DELIM_START = '{'
export const DELIM_END = '}'
/**
* Creates a DraftJS State (content) Interpreting {...} as entities.
* As it uses `createState()` it supports the "selection" DSL.
[
// collapsed selection
['DAVID {Hello [|]World} FINCH', true],
['DAVID {[|]Hello World} FINCH', true],
['DAVID {Hello World[|]} FINCH', true],
['DAVID [|]{Hello World} FINCH', false],
['DAVID {Hello World}[|] FINCH', false],
// expanded selection
['DAVID {Hel[>lo Wo>]rld} FINCH', true],
const doTest = ({ objects, changes, expectedObjects }) => {
const state = {
project: { masterBranch: { objects } }
}
const changeSet = { description: 'A test changeset', project: 'my-project', changes }
expect(project(state, receiveObjectChangeSet(changeSet))).toEqual({
project: {
masterBranch: {
objects: expectedObjects
}
it('should add a new object for a single ADDED change', () => {
doTest({
objects: {
A: { id: 'A', name: 'A' },
B: { id: 'B', name: 'B' },
},
changes: [
{ added: { id: 'NEW', sys: 'marker', data: { children: [] }, project: 'my-project' } }
],
@javierfernandes
javierfernandes / before-doTest.js
Last active November 15, 2020 13:17
RTT-doTest-before
describe('receiveObjectChangeSet()', () => {
describe('ADDED', () => {
it('should add a new object for a single ADDED change', () => {
const state = {
project: {
masterBranch: {
objects: {
A: { id: 'A', name: 'A' },
describe('x / y with x a nil value and y a number', function()
test({
rule = _.div_op(_.var_ref('x'), _.var_ref('y')),
having = { x = nil, y = 12 },
gives = __.unbound_error(nil, 'x'),
at = _.var_ref('x')
})
end)
describe('x / y with x a nil value and y a number', function()
bne.project.set('x', nil)
bne.project.set('y', 12)
local left_expr = _.var_ref('x')
local ast = _.div_op(left_expr, _.var_ref('y'))
local err = __.unbound_error(left_expr, 'x')