Skip to content

Commit

Permalink
fix(subscriptions/detail): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Akanksh Saxena authored and velrest committed Feb 10, 2022
1 parent 899ace4 commit d4131af
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 25 deletions.
2 changes: 1 addition & 1 deletion frontend/app/components/sub-nav/item/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
24 changes: 0 additions & 24 deletions frontend/tests/unit/subscriptions/detail/controller-test.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);
});
});
34 changes: 34 additions & 0 deletions frontend/tests/unit/subscriptions/detail/index/controller-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
34 changes: 34 additions & 0 deletions frontend/tests/unit/subscriptions/detail/orders/controller-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit d4131af

Please sign in to comment.