Skip to content

Commit

Permalink
Add an empty route for a form to change authors on a PREreview
Browse files Browse the repository at this point in the history
Refs #388
  • Loading branch information
thewilkybarkid committed Oct 20, 2022
1 parent 23e1f57 commit 1492653
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
writeReviewAddAuthorMatch,
writeReviewAddAuthorsMatch,
writeReviewAuthorsMatch,
writeReviewChangeAuthorMatch,
writeReviewCompetingInterestsMatch,
writeReviewConductMatch,
writeReviewMatch,
Expand All @@ -52,6 +53,7 @@ import {
writeReviewAddAuthor,
writeReviewAddAuthors,
writeReviewAuthors,
writeReviewChangeAuthor,
writeReviewCompetingInterests,
writeReviewConduct,
writeReviewPersona,
Expand Down Expand Up @@ -133,6 +135,10 @@ export const router: P.Parser<RM.ReaderMiddleware<AppEnv, StatusOpen, ResponseEn
writeReviewAddAuthorMatch.parser,
P.map(({ doi }) => writeReviewAddAuthor(doi)),
),
pipe(
writeReviewChangeAuthorMatch.parser,
P.map(() => writeReviewChangeAuthor()),
),
pipe(
writeReviewRemoveAuthorMatch.parser,
P.map(({ doi, index }) => writeReviewRemoveAuthor(doi, index)),
Expand Down
7 changes: 7 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ export const writeReviewAuthorsMatch = pipe(writeReviewBaseMatch, P.then(P.lit('

export const writeReviewAddAuthorMatch = pipe(writeReviewBaseMatch, P.then(P.lit('add-author')), P.then(P.end))

export const writeReviewChangeAuthorMatch = pipe(
writeReviewBaseMatch,
P.then(P.lit('change-author')),
P.then(type('index', IntegerFromStringC)),
P.then(P.end),
)

export const writeReviewRemoveAuthorMatch = pipe(
writeReviewBaseMatch,
P.then(P.lit('remove-author')),
Expand Down
1 change: 1 addition & 0 deletions src/write-review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { writeReview } from './write-review'
export { writeReviewAddAuthor } from './write-review-add-author'
export { writeReviewAddAuthors } from './write-review-add-authors'
export { writeReviewAuthors } from './write-review-authors'
export { writeReviewChangeAuthor } from './write-review-change-author'
export { writeReviewCompetingInterests } from './write-review-competing-interests'
export { writeReviewConduct } from './write-review-conduct'
export { writeReviewPersona } from './write-review-persona'
Expand Down
3 changes: 3 additions & 0 deletions src/write-review/write-review-change-author.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { notFound } from '../middleware'

export const writeReviewChangeAuthor = () => notFound
22 changes: 22 additions & 0 deletions test/write-review/write-review-change-author.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as E from 'fp-ts/Either'
import { MediaType, Status } from 'hyper-ts'
import * as _ from '../../src/write-review'
import * as fc from '../fc'
import { runMiddleware } from '../middleware'

test('writeReviewChangeAuthor', async () => {
await fc.assert(
fc.asyncProperty(fc.connection({}), async connection => {
const actual = await runMiddleware(_.writeReviewChangeAuthor()({}), connection)()

expect(actual).toStrictEqual(
E.right([
{ type: 'setStatus', status: Status.NotFound },
{ type: 'setHeader', name: 'Cache-Control', value: 'no-store, must-revalidate' },
{ type: 'setHeader', name: 'Content-Type', value: MediaType.textHTML },
{ type: 'setBody', body: expect.anything() },
]),
)
}),
)
})

0 comments on commit 1492653

Please sign in to comment.