Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return a stream', () => {
const result = pipeline(() => { }, empty());
expect(result).to.have.property('source');
});
});
it('should include an array of changed sinks if one or more sinks changed', () => {
const list1 = Collection()
.setInstance('a', {x: most.empty()})
.setInstance('b', {x: most.empty()})
.setInstance('c', {y: most.empty()});
const list2 = list1
.setInstance('c', {z: most.just(1)})
.setInstance('d', {z: most.empty()})
.remove('a', {p: most.empty()});
const {changed} = calculateDiff(null, list1, list2);
assert(!changed.get('b').sinks);
const sinks = changed.get('c').sinks;
assert(Array.isArray(sinks));
assert(sinks.length === 2);
assert(sinks.findIndex(([key, sinks]) => key === 'y' && !sinks) !== -1);
assert(sinks.findIndex(([key, sinks]) => key === 'z' && isStream(sinks)) !== -1);
});
});
it('should return a promise', () => {
const stream = most.empty();
const env = run(stream);
const result = env.tick();
assert.ok(result);
assert.ok('then' in result);
assert.equal(typeof result.then, 'function');
});
it('should list only items that are common to both lists', () => {
const list1 = Collection()
.setInstance('a', {x: most.empty()})
.setInstance('b', {x: most.empty()})
.setInstance('c', {y: most.empty()});
const list2 = list1
.setInstance('c', {z: most.just(1)})
.setInstance('d', {z: most.empty()})
.remove('a', {p: most.empty()});
const {changed} = calculateDiff(null, list1, list2);
assert(changed.size === 2);
assert(changed.has('b'));
assert(changed.has('c'));
});
it('should replace the existing item if the specified key already exists', () => {
const list1 = emptyList.set('firstItem', {}).set('secondItem', {});
assert(!('next' in list1.state.getIn(['items', 'firstItem'], {sinks:{}}).sinks));
const list2 = list1.set('firstItem', {next: most.empty()});
assert(list2.state.get('items').size === 2);
assert('next' in list2.state.getIn(['items', 'firstItem'], {sinks:{}}).sinks);
});
it('should end when the list stream ends', () => {
const bar$ = Collection.merge('bar', most.empty());
const env = run(bar$);
return env.tick(1)
.then(result => {
assert(result.end);
});
});
describe('when only the set of sinks differs', () => {
const last = {index: 7, sinks: {a: most.empty(), b: most.just(1)}};
const next = {index: 7, sinks: {a: last.sinks.a, b: most.just(2)}};
function run() {
return compareItems(null, last, next);
}
it('should exclude the new index', () => {
assert(!('index' in run()));
});
it('should include the sinks comparison', () => {
assert.deepEqual(run(), {sinks: [['b', next.sinks.b]]});
});
});
.continueWith(() => {
entry.stream = most.empty();
compressCache(entry);
return most.empty();
})
.multicast();
constructor(private _mockConfig: MockConfig) {
if ((_mockConfig as any).elements) {
this._elements = (_mockConfig as any).elements;
} else {
this._elements = empty();
}
}
export function getTraversableAst (node, key = null, parents = []) {
let type;
let children;
if (_.isObject(node) && node.type) {
type = NODE;
children = getNodeChildren(node, parents);
} else if (_.isArray(node)) {
type = ARRAY;
children = getArrayChildren(node, parents);
} else {
type = OTHER;
children = most.empty();
}
return { node, type, key, children, parents };
}