Skip to content

Commit

Permalink
Bumped all dependencies, removed PhantomJS.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej.kuster authored and NagRock committed Jul 1, 2021
1 parent 5bad0ab commit 3e51222
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

node_js:
- "8.8.0"
- "14.17.1"

install:
- "npm install"
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function (config) {

reporters: ["progress", "mocha"],

browsers: ["CustomChromeHeadless", "PhantomJS"],
browsers: ["CustomChromeHeadless"],

mochaReporter: {
output: 'minimal'
Expand Down
34 changes: 16 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,25 @@
"javascript"
],
"devDependencies": {
"@types/jasmine": "^2.6.0",
"@types/lodash": "^4.14.104",
"@types/node": "^8.0.46",
"@types/jasmine": "^3.7.7",
"@types/lodash": "^4.14.170",
"@types/node": "^15.14.0",
"babel-polyfill": "^6.26.0",
"jasmine-core": "^2.8.0",
"jest": "^23.5.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.1.0",
"jasmine-core": "^3.7.1",
"jest": "^27.0.6",
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-jasmine": "^4.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"karma-typescript": "^3.0.8",
"karma-typescript-preprocessor": "^0.3.1",
"phantomjs-prebuilt": "^2.1.16",
"puppeteer": "^0.12.0",
"rimraf": "^3.0.0",
"karma-typescript": "^5.5.1",
"karma-typescript-preprocessor": "^0.4.0",
"puppeteer": "^10.1.0",
"rimraf": "^3.0.2",
"ts-helpers": "^1.1.2",
"ts-jest": "^23.0.1",
"tslint": "^5.7.0",
"typescript": "^2.7.2"
"ts-jest": "^27.0.3",
"tslint": "^6.1.3",
"typescript": "^4.3.5"
},
"dependencies": {
"lodash": "^4.17.5"
Expand Down
2 changes: 1 addition & 1 deletion src/Mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class Mocker {
}

private createMethodToStub(key: string): () => any {
return (...args) => {
return (...args: Array<any>) => {
if (args.length === 1 && args[0] === "__tsMockitoGetInfo") {
return {
key,
Expand Down
3 changes: 2 additions & 1 deletion src/utils/MockableFunctionsFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export class MockableFunctionsFinder {
public find(code: string): string[] {
return (code.match(this.functionNameRegex) || [])
.map((match: string) => match.match(this.cleanFunctionNameRegex)[1])
.filter((functionName: string) => this.isMockable(functionName));
.filter((functionName: string) => this.isMockable(functionName))
.map((functionName: string) => functionName.indexOf('=') > 0 ? functionName.substr(0, functionName.indexOf('=')) : functionName);
}

private isMockable(name: string): boolean {
Expand Down
8 changes: 4 additions & 4 deletions test/mocking.getter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ class FooWithGetterAndSetter extends SampleAbstractClass {
super();
}

public sampleMethod(): number {
return 4;
}

public get twoPlusTwo(): number {
return this.dependency.sumTwoNumbers(2, 2);
}

public set twoPlusTwo(value: number) {
this.dependency.sumTwoNumbers(value, 0);
}

public sampleMethod(): number {
return 4;
}
}
36 changes: 18 additions & 18 deletions test/mocking.types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("mocking", () => {
// given

// when
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);
foo = instance(mockedFoo);

// then
Expand All @@ -97,15 +97,15 @@ describe("mocking", () => {
// given

// when
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);

// then
expect((mockedFoo.twoPlusTwo as any) instanceof MethodToStub).toBe(true);
});

it("allows to mock method with generic return type value (with IDE completion)", () => {
// given
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);
foo = instance(mockedFoo);
const expectedResult = new SampleInterfaceImplementation();
when(mockedFoo.getGenericTypedValue()).thenReturn(expectedResult);
Expand All @@ -119,7 +119,7 @@ describe("mocking", () => {

it("does create own property descriptors on instance", () => {
// given
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);
foo = instance(mockedFoo);

// when
Expand All @@ -131,7 +131,7 @@ describe("mocking", () => {

it("does create inherited property descriptors on mock", () => {
// given
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);
foo = instance(mockedFoo);

// when
Expand All @@ -142,7 +142,7 @@ describe("mocking", () => {

it("does create inherited property descriptors on instance", () => {
// given
mockedFoo = mock(SampleGeneric);
mockedFoo = mock<SampleGeneric<SampleInterface>>(SampleGeneric);
foo = instance(mockedFoo);

// when
Expand Down Expand Up @@ -175,17 +175,17 @@ abstract class SampleAbstractClass {
return "sampleString";
}

public sampleMethod(): number {
return 4;
}

public get twoPlusTwo(): number {
return this.dependency.sumTwoNumbers(2, 2);
}

public set twoPlusTwo(value: number) {
this.dependency.sumTwoNumbers(value, 0);
}

public sampleMethod(): number {
return 4;
}
}

class SampleClassWithHasOwnProperty {
Expand All @@ -211,14 +211,6 @@ class SampleInterfaceImplementation implements SampleInterface {
class SampleGeneric<T> {
public dependency: Bar;

public get sampleString(): string {
return "sampleString";
}

public sampleMethod(): number {
return 4;
}

public get twoPlusTwo(): number {
return this.dependency.sumTwoNumbers(2, 2);
}
Expand All @@ -227,6 +219,14 @@ class SampleGeneric<T> {
this.dependency.sumTwoNumbers(value, 0);
}

public get sampleString(): string {
return "sampleString";
}

public sampleMethod(): number {
return 4;
}

public getGenericTypedValue(): T {
return null;
}
Expand Down
8 changes: 4 additions & 4 deletions test/spy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ describe("spying on a real object", () => {
class Real {
public b = 11;

get baz() {
return 3;
}

public foo(a: number) {
return a;
}

public bar() {
return 2;
}

get baz() {
return 3;
}
}

function RealFn() {
Expand Down

0 comments on commit 3e51222

Please sign in to comment.