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

remove dead code #7

Merged
merged 2 commits into from
Jun 15, 2024
Merged
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ts-stubber / [Exports](modules.md)

# ts-stubber

![ts-stubber](https://github.com/ShellyDCMS/ts-stubber/actions/workflows/npm-publish.yml/badge.svg)
Expand Down Expand Up @@ -39,13 +37,14 @@ class MyClass {
throw new Error("Should not be called");
}
}

// creating a stubbed instance using sinon
const sinonStubbedInstanceCreator = StubbedInstanceCreator<MyClass, SinonStub>(
() => sinon.stub()
);

const sinonMockMyClass = sinonStubbedInstanceCreator.createStubbedInstance();

// creating a stubbed instance using jest
const jestStubbedInstanceCreator = StubbedInstanceCreator<MyClass, jest.Mock>(
() => jest.fn()
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ts-stubber",
"description": "Lazy Stubbing a TypeScript Class or Interface with any Mocking Framework for testing in Isolation",
"version": "1.0.4",
"version": "1.0.5",
"author": "Shelly Goldblit",
"private": false,
"license": "MIT",
Expand Down
28 changes: 0 additions & 28 deletions src/stub-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,3 @@ export const StubbedInstanceCreator = <T, StubT>(
};
return { createStubbedInstance };
};

const defaultExcludedMethods: (string | RegExp)[] = [
"__defineGetter__",
"__defineSetter__",
"hasOwnProperty",
"__lookupGetter__",
"__lookupSetter__",
"propertyIsEnumerable",
"toString",
"valueOf",
"__proto__",
"toLocaleString",
"isPrototypeOf",
"then",
/^_\$lit\S+\$$/
];

const shouldExcludeFunction = (
prop: string,
excludedMethods: (string | RegExp)[]
) => {
const matches = excludedMethods.filter((excludedMethod: string | RegExp) =>
typeof excludedMethod === "string"
? excludedMethod === prop
: excludedMethod.test(prop)
);
return matches.length;
};