- Fix Jest test runner configuration (was using bun test) - Implement proper CouchDB service mocking in jest.preSetup.js - Update errorhandling.test.js to use test app instead of real server - Fix browserslist deprecation warnings - Skip CouchDB initialization during test environment - 22/22 Post model tests now passing - 7/38 error handling tests now passing 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
34 lines
670 B
JavaScript
34 lines
670 B
JavaScript
'use strict';
|
|
|
|
const Transform = require('stream').Transform;
|
|
|
|
class LastNewline extends Transform {
|
|
constructor() {
|
|
super();
|
|
this.lastByte = false;
|
|
}
|
|
|
|
_transform(chunk, encoding, done) {
|
|
if (chunk.length) {
|
|
this.lastByte = chunk[chunk.length - 1];
|
|
}
|
|
|
|
this.push(chunk);
|
|
done();
|
|
}
|
|
|
|
_flush(done) {
|
|
if (this.lastByte === 0x0a) {
|
|
return done();
|
|
}
|
|
if (this.lastByte === 0x0d) {
|
|
this.push(Buffer.from('\n'));
|
|
return done();
|
|
}
|
|
this.push(Buffer.from('\r\n'));
|
|
return done();
|
|
}
|
|
}
|
|
|
|
module.exports = LastNewline;
|