diff --git a/test-apps/ember-fetch-v8/public/test-file.json b/test-apps/ember-fetch-v8/public/test-file.json new file mode 100644 index 00000000..cf83bd48 --- /dev/null +++ b/test-apps/ember-fetch-v8/public/test-file.json @@ -0,0 +1,3 @@ +{ + "greeting": "hello there!" +} diff --git a/test-apps/ember-fetch-v8/tests/ember-fetch-test.js b/test-apps/ember-fetch-v8/tests/ember-fetch-test.js new file mode 100644 index 00000000..7e404d30 --- /dev/null +++ b/test-apps/ember-fetch-v8/tests/ember-fetch-test.js @@ -0,0 +1,19 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import { settled } from '@ember/test-helpers'; +// this is bad, because fetch is actually ember-fetch, and we didn't install "fetch" +import fetch from 'fetch'; + +module('ember-fetch@8', function (hooks) { + setupTest(hooks); + + test('it waits for the fetch to be done', async function (assert) { + const promise = fetch('test-file.json'); + + assert.strictEqual(promise._state, undefined); + assert.strictEqual(promise._result, undefined); + await settled(); + assert.strictEqual(promise._state, 1); + assert.strictEqual(promise._result?.statusText, 'OK'); + }); +}); diff --git a/test-apps/ember-fetch-v8/tests/helpers/index.ts b/test-apps/ember-fetch-v8/tests/helpers/index.ts deleted file mode 100644 index 0a16e0be..00000000 --- a/test-apps/ember-fetch-v8/tests/helpers/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { - setupApplicationTest as upstreamSetupApplicationTest, - setupRenderingTest as upstreamSetupRenderingTest, - setupTest as upstreamSetupTest, - SetupTestOptions, -} from 'ember-qunit'; - -// This file exists to provide wrappers around ember-qunit's -// test setup functions. This way, you can easily extend the setup that is -// needed per test type. - -function setupApplicationTest(hooks: NestedHooks, options?: SetupTestOptions) { - upstreamSetupApplicationTest(hooks, options); - - // Additional setup for application tests can be done here. - // - // For example, if you need an authenticated session for each - // application test, you could do: - // - // hooks.beforeEach(async function () { - // await authenticateSession(); // ember-simple-auth - // }); - // - // This is also a good place to call test setup functions coming - // from other addons: - // - // setupIntl(hooks); // ember-intl - // setupMirage(hooks); // ember-cli-mirage -} - -function setupRenderingTest(hooks: NestedHooks, options?: SetupTestOptions) { - upstreamSetupRenderingTest(hooks, options); - - // Additional setup for rendering tests can be done here. -} - -function setupTest(hooks: NestedHooks, options?: SetupTestOptions) { - upstreamSetupTest(hooks, options); - - // Additional setup for unit tests can be done here. -} - -export { setupApplicationTest, setupRenderingTest, setupTest }; diff --git a/test-apps/ember-fetch-v8/tests/integration/.gitkeep b/test-apps/ember-fetch-v8/tests/integration/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/test-apps/ember-fetch-v8/tests/unit/.gitkeep b/test-apps/ember-fetch-v8/tests/unit/.gitkeep deleted file mode 100644 index e69de29b..00000000