DEV: Update tests to remove/ignore classic-class uses (#29440)

In preparation for https://github.com/discourse/discourse/pull/28610
This commit is contained in:
David Taylor 2024-10-28 15:04:29 +00:00 committed by GitHub
parent 92a4b17ad8
commit 8ee00dcbd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 21 deletions

View File

@ -250,6 +250,7 @@ module("Integration | Component | d-button", function (hooks) {
this.set("foo", null); this.set("foo", null);
this.set("legacyActionTriggered", () => this.set("foo", "bar")); this.set("legacyActionTriggered", () => this.set("foo", "bar"));
// eslint-disable-next-line ember/no-classic-classes
this.classicComponent = ClassicComponent.extend({ this.classicComponent = ClassicComponent.extend({
actions: { actions: {
myLegacyAction() { myLegacyAction() {
@ -277,8 +278,9 @@ module("Integration | Component | d-button", function (hooks) {
this.set("foo", null); this.set("foo", null);
this.set("legacyActionTriggered", () => this.set("foo", "bar")); this.set("legacyActionTriggered", () => this.set("foo", "bar"));
this.simpleWrapperComponent = ClassicComponent.extend(); this.simpleWrapperComponent = class extends ClassicComponent {};
// eslint-disable-next-line ember/no-classic-classes
this.classicComponent = ClassicComponent.extend({ this.classicComponent = ClassicComponent.extend({
actions: { actions: {
myLegacyAction() { myLegacyAction() {

View File

@ -76,15 +76,16 @@ module("Unit | Lib | ember-action-modifier", function (hooks) {
}); });
module("used on a classic component", function (innerHooks) { module("used on a classic component", function (innerHooks) {
const ExampleClassicButton = ClassicComponent.extend({ class ExampleClassicButton extends ClassicComponent {
tagName: "", tagName = "";
onDoSomething: null, onDoSomething = null;
doSomething() { doSomething() {
this.onDoSomething?.("doSomething"); this.onDoSomething?.("doSomething");
}, }
}); }
// eslint-disable-next-line ember/no-classic-classes
const ExampleClassicButtonWithActions = ClassicComponent.extend({ const ExampleClassicButtonWithActions = ClassicComponent.extend({
tagName: "", tagName: "",
onDoSomething: null, onDoSomething: null,

View File

@ -1,4 +1,4 @@
import EmberObject from "@ember/object"; import EmberObject, { computed } from "@ember/object";
import { getOwner } from "@ember/owner"; import { getOwner } from "@ember/owner";
import { setupTest } from "ember-qunit"; import { setupTest } from "ember-qunit";
import { module, test } from "qunit"; import { module, test } from "qunit";
@ -10,11 +10,11 @@ module("Unit | Utility | plugin-api", function (hooks) {
setupTest(hooks); setupTest(hooks);
test("modifyClass works with classic Ember objects", function (assert) { test("modifyClass works with classic Ember objects", function (assert) {
// eslint-disable-next-line ember/no-classic-classes
const TestThingy = EmberObject.extend({ const TestThingy = EmberObject.extend({
@discourseComputed prop: computed(function () {
prop() {
return "hello"; return "hello";
}, }),
}); });
getOwner(this).register("test-thingy:main", TestThingy); getOwner(this).register("test-thingy:main", TestThingy);
@ -23,10 +23,9 @@ module("Unit | Utility | plugin-api", function (hooks) {
api.modifyClass("test-thingy:main", { api.modifyClass("test-thingy:main", {
pluginId: "plugin-api-test", pluginId: "plugin-api-test",
@discourseComputed prop: computed(function () {
prop() {
return `${this._super(...arguments)} there`; return `${this._super(...arguments)} there`;
}, }),
}); });
}); });
@ -90,11 +89,11 @@ module("Unit | Utility | plugin-api", function (hooks) {
}); });
test("modifyClass works with getters", function (assert) { test("modifyClass works with getters", function (assert) {
let Base = EmberObject.extend({ let Base = class extends EmberObject {
get foo() { get foo() {
throw new Error("base getter called"); throw new Error("base getter called");
}, }
}); };
getOwner(this).register("test-class:main", Base, { getOwner(this).register("test-class:main", Base, {
instantiate: false, instantiate: false,

View File

@ -7,7 +7,7 @@ module("Unit | Mixin | singleton", function (hooks) {
setupTest(hooks); setupTest(hooks);
test("current", function (assert) { test("current", function (assert) {
let DummyModel = EmberObject.extend({}); let DummyModel = class extends EmberObject {};
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
let current = DummyModel.current(); let current = DummyModel.current();
@ -25,7 +25,7 @@ module("Unit | Mixin | singleton", function (hooks) {
}); });
test("currentProp reading", function (assert) { test("currentProp reading", function (assert) {
let DummyModel = EmberObject.extend({}); let DummyModel = class extends EmberObject {};
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
let current = DummyModel.current(); let current = DummyModel.current();
@ -42,7 +42,7 @@ module("Unit | Mixin | singleton", function (hooks) {
}); });
test("currentProp writing", function (assert) { test("currentProp writing", function (assert) {
let DummyModel = EmberObject.extend({}); let DummyModel = class extends EmberObject {};
DummyModel.reopenClass(Singleton); DummyModel.reopenClass(Singleton);
assert.blank( assert.blank(
@ -73,7 +73,7 @@ module("Unit | Mixin | singleton", function (hooks) {
}); });
test("createCurrent", function (assert) { test("createCurrent", function (assert) {
let Shoe = EmberObject.extend({}); let Shoe = class extends EmberObject {};
Shoe.reopenClass(Singleton, { Shoe.reopenClass(Singleton, {
createCurrent: function () { createCurrent: function () {
return Shoe.create({ toes: 5 }); return Shoe.create({ toes: 5 });
@ -88,7 +88,7 @@ module("Unit | Mixin | singleton", function (hooks) {
}); });
test("createCurrent that returns null", function (assert) { test("createCurrent that returns null", function (assert) {
let Missing = EmberObject.extend({}); let Missing = class extends EmberObject {};
Missing.reopenClass(Singleton, { Missing.reopenClass(Singleton, {
createCurrent: function () { createCurrent: function () {
return null; return null;

View File

@ -1,3 +1,5 @@
// eslint-disable ember/no-classic-classes
import Component from "@ember/component"; import Component from "@ember/component";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { clearRender, render, settled } from "@ember/test-helpers"; import { clearRender, render, settled } from "@ember/test-helpers";

View File

@ -14,6 +14,7 @@ class BarService extends Service {
name = "bar"; name = "bar";
} }
// eslint-disable-next-line ember/no-classic-classes
const EmberObjectComponent = Component.extend({ const EmberObjectComponent = Component.extend({
name: "", name: "",
layout: hbs`<span class="ember-object-component">{{this.foo.name}} {{this.baz.name}}</span>`, layout: hbs`<span class="ember-object-component">{{this.foo.name}} {{this.baz.name}}</span>`,