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

Johanblumenberg matcher types #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LironHazan
Copy link
Collaborator

No description provided.

johanblumenberg and others added 3 commits May 25, 2019 16:05
…-mockito into johanblumenberg-matcher-types

# Conflicts:
#	src/ts-mockito.ts
#	test/matcher/type/DeepEqualMatcher.spec.ts
@codecov-commenter
Copy link

Codecov Report

Merging #8 (3026558) into master (25b8f1d) will increase coverage by 0.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   93.41%   93.64%   +0.23%     
==========================================
  Files          34       36       +2     
  Lines         653      677      +24     
  Branches       80       84       +4     
==========================================
+ Hits          610      634      +24     
  Misses         30       30              
  Partials       13       13              
Impacted Files Coverage Δ
src/matcher/type/EndsWithMatcher.ts 100.00% <100.00%> (ø)
src/matcher/type/StartsWithMatcher.ts 100.00% <100.00%> (ø)
src/ts-mockito.ts 97.01% <100.00%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25b8f1d...3026558. Read the comment docs.

super();
}

public match(value: Object): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

value should be string IMO

import { Matcher } from "./Matcher";

export class EndsWithMatcher extends Matcher {
constructor(private expectedValue: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

expectedValue should be string

import { Matcher } from "./Matcher";

export class StartsWithMatcher extends Matcher {
constructor(private expectedValue: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same type related comments as in endsWithMatcher..

return new MatchingStringMatcher(expectedValue) as any;
}

export function startsWith(expectedValue: string): string {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should return Matcher and no need for the any casting

}

export function endsWith(expectedValue: string): string {
return new EndsWithMatcher(expectedValue) as any;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same here

@@ -12,7 +12,7 @@ describe("MethodAction", () => {
const testObj: MethodAction = new MethodAction(methodName, [firstArg, secondArg]);

// when
const result = testObj.isApplicable(methodName, [strictEqual(firstArg), strictEqual(secondArg)]);
const result = testObj.isApplicable(methodName, [strictEqual(firstArg) as any, strictEqual(secondArg) as any]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

strictEqual should return Matcher and there's no need for casting to any

@LironHazan
Copy link
Collaborator Author

@cspotcode I fixed some of the types in the original PR, a matcher function should return a matcher type not any, the tests were actually expected a matcher.
Regards deepEquality should check if there's a chance of breaking changes as it was loose as well (retuned any) and there's a test that I didn't understand what it aims to achieve, maybe you'll know? (see in my comments) generally I feel there's a lot of place in improving the typing in the project..
I ran the tests, all passed.

@roypeled
Copy link
Collaborator

Is there a reason to no merge this? besides conflicts?

@LironHazan
Copy link
Collaborator Author

Is there a reason to no merge this? besides conflicts?

@roypeled Not that I remember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants