describe('parseTemplate', () => { it('returns a Promise', () => { assert(parseTempatePartial('template') instanceof Promise); }); it('should reject with error for invalid templates', () => { const template = () => new Error('throw'); parseTempatePartial(template()).catch(err => { assert(err instanceof Error); }); }); });
describe('BufferConcatStream', () => { it('concats the input and calls the callback with the result', done => { const st = new BufferConcatStream(result => { assert(result.toString(), 'foobar'); done(); }); st.write(Buffer.from('foo')); st.end(Buffer.from('bar')); }); });
transformInstance.applyTransforms('', childTemplate); const slotMap = mockSerializer.args[0][1].slotMap; assert(slotMap.has('default')); }); transformInstance.applyTransforms('', childTemplate); const slotMap = mockSerializer.args[0][1].slotMap; assert(slotMap.has('default')); }); transformInstance.applyTransforms('', ''); const options = mockSerializer.args[0][1]; assert(options.slotMap instanceof Map); assert(options.treeAdapter instanceof Object); assert.equal(options.pipeTags, pipeTags); assert.equal(options.handleTags, handleTags);
const template = '<blah></blah>'; const serializedList = getSerializer(template).serialize(); assert(serializedList instanceof Array); });
mockParseTemplate ).then(() => { assert(mockParseTemplate.calledOnce); assert(mockParseTemplate.calledWith('<div>test</div>')); }); }); mockParseTemplate ).catch(err => { assert(err.code, 1); assert(err.presentable, 'template not found'); }); }); mockParseTemplate ).then(() => { assert(mockParseTemplate.calledOnce); assert(mockParseTemplate.calledWith('<div>test</div>')); }); }); mockParseTemplate ).then(() => { assert(mockParseTemplate.calledOnce); assert( mockParseTemplate.calledWith( '<div>base-template</div>', mockParseTemplate
describe('ContentLengthStream', () => { it('calculates content length and calls callback with the result', done => { const st = new ContentLengthStream(contentLength => { assert(contentLength, 'foobar'.length); done(); }); st.write(Buffer.from('foo')); st.end(Buffer.from('bar')); }); it('is a Transform stream', () => { const st = new ContentLengthStream(() => {}); assert(st instanceof Transform); }); it('passes through data chunks', done => { const chunk = Buffer.from('foo'); const st = new ContentLengthStream(() => {}); st.on('data', data => { assert.equal(data, chunk); done(); }); st.write(chunk); }); });
assert( headerStart < productStart && headerStart < footerStart, 'header must start before product & footer' ); assert(footerEnd > productEnd, 'footer must be the last to execute'); assert( footerS1Mark > footerS2Mark && footerS1Mark > footerS2Mark, 'footer script 1 would be the last one to start' ); assert( footerS2Mark < footerS3Mark && footerS2MarkEnd > footerS3MarkEnd, 'footer script 2 would start first and exeute after s3' assert( footerS2Measure > 200, 'footer script 2 exec time must be greater than 200ms' assert( footer > footerS1Measure + footerS2Measure + footerS3Measure, 'footer timeline must account for all script tags' assert( productS1Measure > 200, 'product script 2 exec time must be greater than 200ms' assert( product > productS1Measure + productS2Measure, 'product timeline must account for all script tags'
let stream = new StringifierStream(); stream.on('error', error => { assert(error instanceof Error); done(); });
binaryDecode(buffer) { assert(this.config.kafkajs.avroSchema, 'undefined kafka avroSchema'); const avro = avsc.Type.forSchema(this.config.kafkajs.avroSchema); return avro.fromBuffer(buffer); }
const test = (suiteName) => { const testNamePrefix = `${suiteName} it should be able to measure` assert(true, true, `${testNamePrefix} dns lookup time`) assert(true, true, `${testNamePrefix} tcp connection time`) assert(true, true, `${testNamePrefix} tls connection time`) assert(true, true, `${testNamePrefix} time to first byte`) assert(true, true, `${testNamePrefix} content transfer time`) assert(true, true, `${testNamePrefix} total request response time`) assert(true, true, `${testNamePrefix} Request header start time`) assert(true, true, `${testNamePrefix} Request header complete time`) assert(true, true, `${testNamePrefix} Request body start time`) assert(true, true, `${testNamePrefix} Request body complete time`) assert(true, true, `${testNamePrefix} Response header start time`) assert(true, true, `${testNamePrefix} Response header complete time`) assert(true, true, `${testNamePrefix} Response body start time`) assert(true, true, `${testNamePrefix} Response body complete time`) }
describe('Fabrix App', () => { it('should exist', () => { assert(global.app) }) })
binaryEncode(data) { assert(this.config.kafkajs.avroSchema, 'undefined kafka avroSchema'); const avro = avsc.Type.forSchema(this.config.kafkajs.avroSchema); return avro.toBuffer(data); }