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

adding setupSinon function to dummy/index.d.ts to allow for types in … #763

Merged
merged 4 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 9 additions & 11 deletions tests/unit/setup-sinon-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { module, test } from 'qunit';
import QUnit, { module, test } from 'qunit';
import setupSinon from 'ember-sinon-qunit';
import {
createSandbox,
Expand All @@ -11,17 +11,15 @@ module('Unit | ember-sinon-qunit | Setup in testStart/testDone', function () {

let testStartCalled = false;
let testDoneCalled = false;
const qunit = QUnit;

let qunit = {
testStart(callback = () => {}) {
testStartCalled = true;
assert.strictEqual(callback, createSandbox);
},

testDone(callback = () => {}) {
testDoneCalled = true;
assert.strictEqual(callback, restoreSandbox);
},
qunit.testDone = (callback = () => {}) => {
testDoneCalled = true;
assert.strictEqual(callback, restoreSandbox);
};
qunit.testStart = (callback = () => {}) => {
testStartCalled = true;
assert.strictEqual(callback, createSandbox);
};

setupSinon(qunit);
Expand Down
4 changes: 3 additions & 1 deletion types/dummy/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

declare module 'ember-sinon-qunit' {
export default function setupSinon(testEnvironment: Partial<QUnit>): void;
Copy link
Owner

Choose a reason for hiding this comment

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

This won't be a Partial anymore, right?

Copy link
Owner

@elwayman02 elwayman02 Mar 14, 2023

Choose a reason for hiding this comment

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

Actually, nvm, I think Partial is the right way to type it because they may in theory supply their own modified test environment with the same two methods to hook into.

Copy link
Contributor Author

@robostheimer robostheimer Mar 14, 2023

Choose a reason for hiding this comment

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

In that case, I think that we’d want to with our own interface, given that we do not know for sure the their test environment is QUnit but we do know the methods they will be using.

interface TestEnvironmentInterface {
  testStart: (callback: () => void) => void
  testDone: (callback: () => void) => void
}

All that said the addon is called ember-sinon-qunit so aren’t we implying consumers will be using QUnit.

Copy link
Owner

Choose a reason for hiding this comment

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

I think it's fine. If we run into a legit use-case, we can always go back and modify the types in a later release.

}
1 change: 0 additions & 1 deletion types/ember-sinon-qunit.d.ts

This file was deleted.