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

headstart #254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/operations/headstart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
name: "head start",
url: "/headstart/:name/:from",
fields: [
{ name: "Name", field: "name" },
{ name: "From", field: "from" },
],
register(app, output) {
return app.get("/headstart/:name/:from", function (req, res) {
const message = `${req.params.name}, if you started fucking off now, you would have a head start`;
const subtitle = `- ${req.params.from}`;
return output(req, res, message, subtitle);
});
},
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions spec/operations/headstart_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const operation = require('../../lib/operations/headstart')

describe('/headstart', function () {
it('should have the correct name', () => expect(operation.name).toEqual('head start'))

it('should have the correct url', () => expect(operation.url).toEqual('/headstart/:name/:from'))

it('should have the correct fields', () =>
expect(operation.fields).toEqual([
{ name: 'Name', field: 'name' },
{ name: 'From', field: 'from' }
])
)

return describe('register', function () {
it('should call app.get with correct url', function () {
const app =
{ get: jasmine.createSpy() }

operation.register(app, null)

expect(app.get).toHaveBeenCalledWith('/headstart/:name/:from', jasmine.any(Function))
})

return it('should call output with correct params', function () {
let func = null
const app =
{ get (url, fn) { return func = fn } }
const output = jasmine.createSpy()
operation.register(app, output)

const req = {
params: {
company: 'TESTCOMPANY',
from: 'TESTFROM'
}
}

const message = `${req.params.name}, if you started fucking off now, you would have a head start`
const subtitle = `- ${req.params.from}`

func(req, 'RES')
return expect(output).toHaveBeenCalledWith(req, 'RES', message, subtitle)
})
})
})