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

[CLEANUP] Convert ember-metal/watching tests to new style #16072

Merged
merged 1 commit into from
Jan 11, 2018

Conversation

thoov
Copy link
Member

@thoov thoov commented Jan 5, 2018

Apart of #15988

@@ -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) {
Copy link
Member Author

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

Copy link
Member

@rwjblue rwjblue Jan 5, 2018

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); } 
    };
  }
}

@rwjblue rwjblue mentioned this pull request Jan 7, 2018
14 tasks
while (proto !== Object.prototype) {
Object.keys(proto).forEach(generateTest);
if(proto instanceof ObjectAccessorTestCase && !ENV.USES_ACCESSORS) {
Copy link
Member Author

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.

Copy link
Member

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? 🤔

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Kill it with 🔥

Copy link
Member Author

Choose a reason for hiding this comment

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

simpsons-fire

@thoov
Copy link
Member Author

thoov commented Jan 9, 2018

@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.

@thoov
Copy link
Member Author

thoov commented Jan 9, 2018

I have added a line item for testBoth removal in #15988

@rwjblue rwjblue merged commit 246eba5 into emberjs:master Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants