Skip to content

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

Merged
rwjblue merged 1 commit into
emberjs:masterfrom
thoov:ember-metal-testboth
Jan 11, 2018
Merged

rwjblue merged 1 commit into
emberjs:masterfrom
thoov:ember-metal-testboth

Conversation

@thoov

@thoov thoov commented Jan 5, 2018 •

Copy link
Copy Markdown
Member

Apart of #15988

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
Copy Markdown
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

@rwjblue rwjblue Jan 5, 2018 •

Copy link
Copy Markdown
Member

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
13 of 14 tasks

while (proto !== Object.prototype) {
Object.keys(proto).forEach(generateTest);
if(proto instanceof ObjectAccessorTestCase && !ENV.USES_ACCESSORS) {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

thoov commented Jan 9, 2018

Copy link
Copy Markdown
Member Author

@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

thoov commented Jan 9, 2018 •

Copy link
Copy Markdown
Member Author

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

@thoov
thoov force-pushed the ember-metal-testboth branch from eca37d4 to 756b0d1 Compare January 10, 2018 22:49
@thoov
thoov force-pushed the ember-metal-testboth branch from 756b0d1 to b36da19 Compare January 10, 2018 22:51
@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