Skip to content

Tests for the Session API#3967

Merged
DanielRosenwasser merged 5 commits into
microsoft:masterfrom
weswigham:issues/3813
Jul 23, 2015
Merged

Tests for the Session API#3967
DanielRosenwasser merged 5 commits into
microsoft:masterfrom
weswigham:issues/3813

Conversation

@weswigham
Copy link
Copy Markdown
Member

Additionally, I added visibility modifiers to all the members, so we declare public as little as is required.

When merged, this should close issue #3813.

Comment thread tests/cases/unittests/session.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 4 spaces instead of tabs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn, that was unintentional. I hate tabs. Can we modify the tslint to pick up on this, too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that's a good idea.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jul 22, 2015

looks good to me, along with @DanielRosenwasser's comments. @zhengbli can you take a look as well.

@weswigham
Copy link
Copy Markdown
Member Author

Re: All my responses mentioning tslint - on further investigation most of them should have been picked up by out current tslint settings according to the tslint documentation, but these ones didn't seem to get reported when I ran a pass.

I looked into it a bit and found the following:
quotemark and indent are both just true - the docs says this only requires consistency so when you only run tslint on a single file.... it doesn't really help much in the project-wide sense.
indent should probably have [true, "spaces"] added to its argument list (Found that gem in a PR, the docs don't seem to have been updated with it) - but actually looking over the source, only passing true means it does nothing to check indents at all. Similarly, "quotemark" should actually bet set to [true, "double"] rather than simply true to actually be on, looking at that rule's source it's not actually run without either "single" or "double" specified.
"typedef-whitespace": "nospace" should be added to the tslint to capture the error of having a space before the colon.
And I'm not sure tslint has a rule covering multiple declarations at present... I know jslint can (and, by default, has you combine them, hence my style). May need to request/make a new rule to capture that?

This is probably a result of having a tslint dependency of latest and not keeping the tslint file up to date with the bleeding edge of tslint itself (2.4.0-2 was released 3 days ago/today/yesterday).

Comment thread tests/cases/unittests/session.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you define a type alias for Session & {enqueue: (msg: protocol.Request) => void}?

You can also do this within functions so it can be local to the containing function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS doesn't allow local type aliases (? has this changed recently?) and I'd been trying to keep all the types internal to the test. So I'd have to hoist the alias all the way out to the ambient level despite no other tests or types in the module depending on it. Eh?

Makes me want local type aliases.

@DanielRosenwasser
Copy link
Copy Markdown
Member

@weswigham thanks for pointing out the lack of TSLint rules, I've created #3994 to track the issue.

Comment thread tests/cases/unittests/session.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a method call?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the line probably shouldn't be there at all... Really, I effectively wanted an assert(true) after calling session.exit() to indicate that the process should still be running. I'm not really sure how to test that a function which should be a noop is, in fact, still a noop. (Beyond literally stringifying the function and checking it's source, which seems extremely tautological)

Actually, in every case Session gets subclassed - maybe we should just mark Session as abstract and exit() as an abstract method (then remove the test)? I think that may be more in line with what is supposed to occur.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with that as a separate PR. In the mean time, consider removing the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants