Skip to content

Commit

Permalink
Merge pull request #345 from cibernox/fix-tests
Browse files Browse the repository at this point in the history
Move test import `ember-power-calendar/test-support` to `ember-power-calendar/test-support/helpers`
  • Loading branch information
mkszepp authored Jan 4, 2024
2 parents 190b5b5 + 484eec7 commit 559c8a0
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/app/templates/public-pages/docs/test-helpers.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<p>
<strong>Important note:</strong> Since version 0.6.0, all the test helpers can also be imported like
<code>import { calendarCenter, calendarSelect } from 'ember-power-calendar/test-support';</code> and used
<code>import { calendarCenter, calendarSelect } from 'ember-power-calendar/test-support/helpers';</code> and used
indistinctly in acceptance or integration tests, with or without async/await. If you use this approach
you don't need to register them as global helpers anymore.
</p>
Expand Down Expand Up @@ -59,7 +59,7 @@
<h2>Integration Tests</h2>

<p>
Just import the helpers like <code>import { calendarCenter, calendarSelect } from 'ember-power-calendar/test-support';</code>
Just import the helpers like <code>import { calendarCenter, calendarSelect } from 'ember-power-calendar/test-support/helpers';</code>
and use them as any other helper 😀
</p>

Expand Down
3 changes: 2 additions & 1 deletion ember-power-calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
"./components/power-calendar/nav.js": "./dist/_app_/components/power-calendar/nav.js",
"./helpers/ember-power-calendar-day-classes.js": "./dist/_app_/helpers/ember-power-calendar-day-classes.js",
"./helpers/power-calendar-format-date.js": "./dist/_app_/helpers/power-calendar-format-date.js",
"./services/power-calendar.js": "./dist/_app_/services/power-calendar.js"
"./services/power-calendar.js": "./dist/_app_/services/power-calendar.js",
"./test-support/helpers.js": "./dist/_app_/test-support/helpers.js"
}
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions ember-power-calendar/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default [
'components/**/*.js',
'helpers/*.js',
'services/*.js',
'test-support/*.js',
]),

// Follow the V2 Addon rules about dependencies. Your code can import from
Expand Down
6 changes: 4 additions & 2 deletions ember-power-calendar/src/components/power-calendar-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
normalizeDuration,
} from '../utils';
import { assert } from '@ember/debug';

import ownProp from '../-private/utils/own-prop';
import PowerCalendarRangeComponent from './power-calendar-range/days';

export default class extends CalendarComponent {
Expand Down Expand Up @@ -173,3 +171,7 @@ export default class extends CalendarComponent {
return normalizeRangeActionValue({ date: { start: day.date, end: null } });
}
}

function ownProp(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { run } from '@ember/runloop';
import { assert } from '@ember/debug';
import { click, settled, find } from '@ember/test-helpers';
import { formatDate } from './utils';
import { formatDate } from '../utils';

export * from '../utils';

function findCalendarElement(selector) {
let target = find(selector);
Expand Down
3 changes: 0 additions & 3 deletions test-app/app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import Controller from '@ember/controller';
import {} from 'ember-power-calendar/utils';
// eslint-disable-next-line ember/no-test-support-import
import {} from 'ember-power-calendar/test-support';

export default class extends Controller {}
File renamed without changes.
2 changes: 1 addition & 1 deletion test-app/tests/acceptance/helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { visit, click } from '@ember/test-helpers';
import {
calendarCenter,
calendarSelect,
} from 'ember-power-calendar/test-support';
} from 'ember-power-calendar/test-support/helpers';

module('Acceptance | helpers | calendarCenter', function (hooks) {
setupApplicationTest(hooks);
Expand Down
2 changes: 1 addition & 1 deletion test-app/tests/assertions/is-calendar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ownProp from 'ember-power-calendar/-private/utils/own-prop';
import ownProp from 'test-app/utils/own-prop';

export default function isCalendar(calendar, message) {
let result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';
import { run } from '@ember/runloop';
import { isSame, formatDate } from 'ember-power-calendar/utils';
import { isSame, formatDate } from 'ember-power-calendar/test-support/helpers';

module('Integration | Component | <PowerCalendarMultiple>', function (hooks) {
setupRenderingTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';

module(
'Integration | Component | <PowerCalendarMultiple::Days>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';
import { run } from '@ember/runloop';
import { isSame } from 'ember-power-calendar/utils';

import ownProp from 'ember-power-calendar/-private/utils/own-prop';
import { isSame } from 'ember-power-calendar/test-support/helpers';
import ownProp from 'test-app/utils/own-prop';

module('Integration | Component | <PowerCalendarRange>', function (hooks) {
setupRenderingTest(hooks);
Expand Down Expand Up @@ -154,7 +153,6 @@ module('Integration | Component | <PowerCalendarRange>', function (hooks) {
});

test('When an range date object is passed, the range selection behavior is skipped', async function (assert) {
assert.expect(4);
this.rangeToSelect = { date: { start: undefined, end: undefined } };
this.selected = {
date: { start: new Date(2013, 9, 5), end: new Date(2013, 9, 10) },
Expand Down
5 changes: 2 additions & 3 deletions test-app/tests/integration/components/power-calendar-test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click, focus, triggerKeyEvent } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';
import { run, later } from '@ember/runloop';
import RSVP from 'rsvp';
import require from 'require';
import { importSync } from '@embroider/macros';

import ownProp from 'ember-power-calendar/-private/utils/own-prop';
import ownProp from 'test-app/utils/own-prop';

const dateLibrary = require.has('luxon') ? 'luxon' : 'moment';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';
import { run } from '@ember/runloop';
import require from 'require';
import { TrackedObject } from 'tracked-built-ins';

import ownProp from 'ember-power-calendar/-private/utils/own-prop';
import ownProp from 'test-app/utils/own-prop';

const dateLibrary = require.has('luxon') ? 'luxon' : 'moment';
let calendarService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { hbs } from 'ember-cli-htmlbars';
import { run } from '@ember/runloop';

let calendarService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { calendarCenter } from 'ember-power-calendar/test-support';
import { hbs } from 'ember-cli-htmlbars';
import { calendarCenter } from 'ember-power-calendar/test-support/helpers';

module('Test Support | Helper | calendarCenter', function (hooks) {
setupRenderingTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { calendarSelect } from 'ember-power-calendar/test-support';
import { hbs } from 'ember-cli-htmlbars';
import { calendarSelect } from 'ember-power-calendar/test-support/helpers';

module('Test Support | Helper | calendarSelect', function (hooks) {
setupRenderingTest(hooks);
Expand Down
2 changes: 1 addition & 1 deletion test-app/tests/unit/utils/date-utils-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { module, test } from 'qunit';
import { add } from 'ember-power-calendar/utils';
import { add } from 'ember-power-calendar/test-support/helpers';

module('Unit | Utility | date-utils', function () {
test('can add seconds', function (assert) {
Expand Down

0 comments on commit 559c8a0

Please sign in to comment.