Repository navigation
[CLEANUP] Convert ember-metal/watching tests to new style - #16072
Conversation
| 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.
@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.
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.
@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.
Do we ever set that ENV flag? I wonder why it exists? 🤔
There was a problem hiding this comment.
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?
|
@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