Skip to content

typescript please! #107

Open
Open
@jmagaram

Description

@jmagaram

Desperately needing samples in TypeScript. I'm trying to test functions now and don't have a clue what parameters are possible on Request and Response objects. Have Googled for hours and can't find what I need. Would love to see some really basic function tests in Mocha and Typescript against the emulator. Tests for...

HTTP
If function is supposed to return an uppercase version of what is passed in, check that
Function grabs parameters out of the query string
If function is supposed to return an error code, like forbidden, show that
If function is supposed to write to a document
Fail if not authenticated, return proper status code
Check claims, fail if not met

INTERNAL SERVER
On user create, create a document
On user delete, delete a document
On document changes, do something

===

Digging through your code a bit I see references to "core" and Express. Can I even get these types into my code? I'd like to strongly type my request and response objects. Where do I import these from?

===

Investigated some more and see it is Express web server under the covers? I'm going to assume that testing this in Typescript is going to be tough because there are so many possible properties on the Request object - headers and such - and so many ways to build the response and I'd need test helpers to construct these things in such a way that they'd type check. Also don't know how this interacts with the Auth stuff - do I get the token from the headers or from the Auth API. This is really beyond me - too much to learn - probably will just skip the unit testing. Can't do it without some getting started info from you with common cases in code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions