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 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 } | |
], |
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
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) => ({ |
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 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(','), |
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 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. |
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
[ | |
// 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], |
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 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 | |
} |
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
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' } } | |
], | |
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
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' }, |
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
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) |
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
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') |
NewerOlder