From d4131af84c1f14056878a931809af71e37fc44cd Mon Sep 17 00:00:00 2001 From: Akanksh Saxena Date: Thu, 3 Feb 2022 10:56:30 +0100 Subject: [PATCH] fix(subscriptions/detail): update tests --- .../app/components/sub-nav/item/component.js | 2 +- .../heading-search/component-test.js | 0 .../data-table/heading-sort/component-test.js | 0 .../nav-breadcrumbs/component-test.js | 0 .../components/project-info/component-test.js | 0 .../subscriptions/detail/controller-test.js | 24 ------------- .../detail/index/controller-test.js | 34 +++++++++++++++++++ .../detail/orders/controller-test.js | 34 +++++++++++++++++++ 8 files changed, 69 insertions(+), 25 deletions(-) rename frontend/tests/integration/{ui => }/components/data-table/heading-search/component-test.js (100%) rename frontend/tests/integration/{ui => }/components/data-table/heading-sort/component-test.js (100%) rename frontend/tests/integration/{ui => }/components/nav-breadcrumbs/component-test.js (100%) rename frontend/tests/integration/{ui => }/components/project-info/component-test.js (100%) create mode 100644 frontend/tests/unit/subscriptions/detail/index/controller-test.js create mode 100644 frontend/tests/unit/subscriptions/detail/orders/controller-test.js diff --git a/frontend/app/components/sub-nav/item/component.js b/frontend/app/components/sub-nav/item/component.js index 32305a92..34e63af4 100644 --- a/frontend/app/components/sub-nav/item/component.js +++ b/frontend/app/components/sub-nav/item/component.js @@ -5,6 +5,6 @@ export default class SubNavItemComponent extends Component { @service router; get isActive() { - return this.router.currentRoute.name.includes(this.args.route); + return this.router.currentRoute?.name.includes(this.args.route); } } diff --git a/frontend/tests/integration/ui/components/data-table/heading-search/component-test.js b/frontend/tests/integration/components/data-table/heading-search/component-test.js similarity index 100% rename from frontend/tests/integration/ui/components/data-table/heading-search/component-test.js rename to frontend/tests/integration/components/data-table/heading-search/component-test.js diff --git a/frontend/tests/integration/ui/components/data-table/heading-sort/component-test.js b/frontend/tests/integration/components/data-table/heading-sort/component-test.js similarity index 100% rename from frontend/tests/integration/ui/components/data-table/heading-sort/component-test.js rename to frontend/tests/integration/components/data-table/heading-sort/component-test.js diff --git a/frontend/tests/integration/ui/components/nav-breadcrumbs/component-test.js b/frontend/tests/integration/components/nav-breadcrumbs/component-test.js similarity index 100% rename from frontend/tests/integration/ui/components/nav-breadcrumbs/component-test.js rename to frontend/tests/integration/components/nav-breadcrumbs/component-test.js diff --git a/frontend/tests/integration/ui/components/project-info/component-test.js b/frontend/tests/integration/components/project-info/component-test.js similarity index 100% rename from frontend/tests/integration/ui/components/project-info/component-test.js rename to frontend/tests/integration/components/project-info/component-test.js diff --git a/frontend/tests/unit/subscriptions/detail/controller-test.js b/frontend/tests/unit/subscriptions/detail/controller-test.js index 5d281b59..c87355ed 100644 --- a/frontend/tests/unit/subscriptions/detail/controller-test.js +++ b/frontend/tests/unit/subscriptions/detail/controller-test.js @@ -1,4 +1,3 @@ -import { A } from "@ember/array"; import { setupIntl } from "ember-intl/test-support"; import { setupTest } from "ember-qunit"; import { module, test } from "qunit"; @@ -11,27 +10,4 @@ module("Unit | Controller | subscriptions/detail", function (hooks) { const controller = this.owner.lookup("controller:subscriptions/detail"); assert.ok(controller); }); - - test("it works", function (assert) { - const controller = this.owner.lookup("controller:subscriptions/detail"); - - const project = {}; - const orders = []; - orders.links = { next: "..." }; - const reports = []; - reports.links = { next: "..." }; - - const model = { project, orders, reports }; - controller.setup(model); - - assert.deepEqual(controller.project, project); - - assert.deepEqual(controller.orders, orders.toArray()); - assert.strictEqual(controller.ordersPage, 1); - assert.true(controller.ordersNext); - - assert.deepEqual(controller.reports, reports.toArray()); - assert.strictEqual(controller.reportsPage, 1); - assert.true(controller.reportsNext); - }); }); diff --git a/frontend/tests/unit/subscriptions/detail/index/controller-test.js b/frontend/tests/unit/subscriptions/detail/index/controller-test.js new file mode 100644 index 00000000..e3ff5366 --- /dev/null +++ b/frontend/tests/unit/subscriptions/detail/index/controller-test.js @@ -0,0 +1,34 @@ +import { setupIntl } from "ember-intl/test-support"; +import { setupTest } from "ember-qunit"; +import { module, test } from "qunit"; + +module("Unit | Controller | subscriptions/detail/index", function (hooks) { + setupTest(hooks); + setupIntl(hooks, "en"); + + test("it exists", function (assert) { + const controller = this.owner.lookup( + "controller:subscriptions/detail/index" + ); + assert.ok(controller); + }); + + test("it works", function (assert) { + const controller = this.owner.lookup( + "controller:subscriptions/detail/index" + ); + + const project = {}; + const reports = []; + reports.links = { next: "..." }; + + const model = { project, reports }; + controller.setup(model); + + assert.deepEqual(controller.project, project); + + assert.deepEqual(controller.reports, reports.toArray()); + assert.strictEqual(controller.reportsPage, 1); + assert.true(controller.reportsNext); + }); +}); diff --git a/frontend/tests/unit/subscriptions/detail/orders/controller-test.js b/frontend/tests/unit/subscriptions/detail/orders/controller-test.js new file mode 100644 index 00000000..d4cff19d --- /dev/null +++ b/frontend/tests/unit/subscriptions/detail/orders/controller-test.js @@ -0,0 +1,34 @@ +import { setupIntl } from "ember-intl/test-support"; +import { setupTest } from "ember-qunit"; +import { module, test } from "qunit"; + +module("Unit | Controller | subscriptions/detail/orders", function (hooks) { + setupTest(hooks); + setupIntl(hooks, "en"); + + test("it exists", function (assert) { + const controller = this.owner.lookup( + "controller:subscriptions/detail/orders" + ); + assert.ok(controller); + }); + + test("it works", function (assert) { + const controller = this.owner.lookup( + "controller:subscriptions/detail/orders" + ); + + const project = {}; + const orders = []; + orders.links = { next: "..." }; + + const model = { project, orders }; + controller.setup(model); + + assert.deepEqual(controller.project, project); + + assert.deepEqual(controller.orders, orders.toArray()); + assert.strictEqual(controller.ordersPage, 1); + assert.true(controller.ordersNext); + }); +});