-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[CLEANUP] Convert ember-metal/watching tests to new style #16072
Conversation
@@ -62,6 +63,8 @@ export default function moduleFor(description, TestClass, ...mixins) { | |||
function generateTest(name) { | |||
if (name.indexOf('@test ') === 0) { | |||
QUnit.test(name.slice(5), assert => context[name](assert)); | |||
} else if (name.indexOf('@testBoth ') === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue Im not sure about @testBoth
but Im not sure how we want to do this conceptually since we are trying to write "one" test that behind the scenes translates to 2.
I was thinking of something like:
['@test foo'](assert) {
const done = assert.async();
testBoth('foo', (get, set, assert) {
}, done);
}
But its going to create:
QUnit.test('foo', () => {
QUnit.test('foo 1', () => {})
QUnit.test('foo 2', () => {})
});
And I dont think that is right either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places we have extracted the tests into a single class, then used getters for the "swappable" bits.
something like:
class SomeStuffTest extends AccessorTests {
['@test does something or other'](assert) {
let { get, set } = this.accessors;
// normal test here;
}
}
moduleFor('asdfasdf', class ThisGetAccessorTest extends SomeStuffTest {
get accessors() {
return {
get(key) { return Ember.get(obj, key); },
set(key, value) { return Ember.set(obj, key, value); }
};
}
}
moduleFor('asdfasdf', class ThisGetAccessorTest extends SomeStuffTest {
get accessors() {
return {
get(key) { return obj.get(key); },
set(key, value) { return obj.set(key, value); }
};
}
}
while (proto !== Object.prototype) { | ||
Object.keys(proto).forEach(generateTest); | ||
if(proto instanceof ObjectAccessorTestCase && !ENV.USES_ACCESSORS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue I converted over to your example. This is probably the only "weirdness" and needed to support this functionality. Let me know your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever set that ENV flag? I wonder why it exists? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just grepped and can't find any usage of it nor can I find when this was added when looking at the git history. Now looking at this deeper seems like testBoth has never been "testing" both and instead just doing dummy asserts on the non ember metal side. Do you think we should remove this behavior or attempt to support it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kill it with 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue I have updated this and it no longer uses the testboth method and I will refactor the other tests away from that in separate PRs. |
I have added a line item for testBoth removal in #15988 |
eca37d4
to
756b0d1
Compare
756b0d1
to
b36da19
Compare
Apart of #15988