Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added chained "pipe" function formatting tests #6818

Merged
merged 4 commits into from Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
186 changes: 186 additions & 0 deletions tests/functional_composition/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -258,6 +258,192 @@ MongoClient.connect("mongodb://localhost:27017/posts", (err, db) => {
================================================================================
`;

exports[`pipe-function-calls.js 1`] = `
====================================options=====================================
parsers: ["flow", "babel", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// input is formatted correctly according to prettier@1.18.2

(() => {
pipe(
timelines,
everyCommitTimestamps,
A.sort(ordDate),
A.head
);

pipe(
serviceEventFromMessage(msg),
TE.chain(
flow(
publishServiceEvent(analytics),
TE.mapLeft(nackFromError)
)
)
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(
O.fromNullable(err.stack),
O.getOrElse(constant(err.message))
)
);
process.exit(1);
});

pipe(
Changelog.timestampOfFirstCommit([[commit]]),
O.toUndefined
);

chain(
flow(
getUploadUrl,
E.mapLeft(Errors.unknownError),
TE.fromEither
)
);
})();

=====================================output=====================================
// input is formatted correctly according to prettier@1.18.2

(() => {
pipe(timelines, everyCommitTimestamps, A.sort(ordDate), A.head);

pipe(
serviceEventFromMessage(msg),
TE.chain(flow(publishServiceEvent(analytics), TE.mapLeft(nackFromError)))
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(O.fromNullable(err.stack), O.getOrElse(constant(err.message)))
);
process.exit(1);
});

pipe(Changelog.timestampOfFirstCommit([[commit]]), O.toUndefined);

chain(flow(getUploadUrl, E.mapLeft(Errors.unknownError), TE.fromEither));
})();

================================================================================
`;

exports[`pipe-function-calls-with-comments.js 1`] = `
====================================options=====================================
parsers: ["flow", "babel", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// input with some comments added to avoid reformatting

(() => {
pipe(
// add a descriptive comment here
timelines,
everyCommitTimestamps,
A.sort(ordDate),
A.head
);

pipe(
// add a descriptive comment here
serviceEventFromMessage(msg),
TE.chain(
flow(
// add a descriptive comment here
publishServiceEvent(analytics),
TE.mapLeft(nackFromError)
)
)
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(
// add a descriptive comment here
O.fromNullable(err.stack),
O.getOrElse(constant(err.message))
)
);
process.exit(1);
});

pipe(
// add a descriptive comment here
Changelog.timestampOfFirstCommit([[commit]]),
O.toUndefined
);

chain(
flow(
// add a descriptive comment here
getUploadUrl,
E.mapLeft(Errors.unknownError),
TE.fromEither
)
);
})();

=====================================output=====================================
// input with some comments added to avoid reformatting

(() => {
pipe(
// add a descriptive comment here
timelines,
everyCommitTimestamps,
A.sort(ordDate),
A.head
);

pipe(
// add a descriptive comment here
serviceEventFromMessage(msg),
TE.chain(
flow(
// add a descriptive comment here
publishServiceEvent(analytics),
TE.mapLeft(nackFromError)
)
)
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(
// add a descriptive comment here
O.fromNullable(err.stack),
O.getOrElse(constant(err.message))
)
);
process.exit(1);
});

pipe(
// add a descriptive comment here
Changelog.timestampOfFirstCommit([[commit]]),
O.toUndefined
);

chain(
flow(
// add a descriptive comment here
getUploadUrl,
E.mapLeft(Errors.unknownError),
TE.fromEither
)
);
})();

================================================================================
`;

exports[`ramda_compose.js 1`] = `
====================================options=====================================
parsers: ["flow", "babel", "typescript"]
Expand Down
49 changes: 49 additions & 0 deletions tests/functional_composition/pipe-function-calls-with-comments.js
@@ -0,0 +1,49 @@
// input with some comments added to avoid reformatting

(() => {
pipe(
// add a descriptive comment here
timelines,
everyCommitTimestamps,
A.sort(ordDate),
A.head
);

pipe(
// add a descriptive comment here
serviceEventFromMessage(msg),
TE.chain(
flow(
// add a descriptive comment here
publishServiceEvent(analytics),
TE.mapLeft(nackFromError)
)
)
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(
// add a descriptive comment here
O.fromNullable(err.stack),
O.getOrElse(constant(err.message))
)
);
process.exit(1);
});

pipe(
// add a descriptive comment here
Changelog.timestampOfFirstCommit([[commit]]),
O.toUndefined
);

chain(
flow(
// add a descriptive comment here
getUploadUrl,
E.mapLeft(Errors.unknownError),
TE.fromEither
)
);
})();
43 changes: 43 additions & 0 deletions tests/functional_composition/pipe-function-calls.js
@@ -0,0 +1,43 @@
// input is formatted correctly according to prettier@1.18.2

(() => {
pipe(
timelines,
everyCommitTimestamps,
A.sort(ordDate),
A.head
);

pipe(
serviceEventFromMessage(msg),
TE.chain(
flow(
publishServiceEvent(analytics),
TE.mapLeft(nackFromError)
)
)
)()
.then(messageResponse(logger, msg))
.catch((err: Error) => {
logger.error(
pipe(
O.fromNullable(err.stack),
O.getOrElse(constant(err.message))
)
);
process.exit(1);
});

pipe(
Changelog.timestampOfFirstCommit([[commit]]),
O.toUndefined
);

chain(
flow(
getUploadUrl,
E.mapLeft(Errors.unknownError),
TE.fromEither
)
);
})();