From 1c9b310ea66016e833f3e986464468e30c20f2a8 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Thu, 24 Feb 2022 18:02:21 -0500 Subject: [PATCH] Add a test for the positive case for successful transformation of '@cached' --- tests/scenarios/glimmer-tracking-test.ts | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/scenarios/glimmer-tracking-test.ts diff --git a/tests/scenarios/glimmer-tracking-test.ts b/tests/scenarios/glimmer-tracking-test.ts new file mode 100644 index 000000000..1cde2ad5b --- /dev/null +++ b/tests/scenarios/glimmer-tracking-test.ts @@ -0,0 +1,61 @@ +import { appReleaseScenario } from './scenarios'; +import { PreparedApp } from 'scenario-tester'; +import QUnit from 'qunit'; +import merge from 'lodash/merge'; +const { module: Qmodule, test } = QUnit; + +appReleaseScenario + .map('transform @glimmer/tracking', project => { + merge(project.files, { + app: { + components: { + 'demo.js': ` + import Component from '@glimmer/component'; + import { cached } from '@glimmer/tracking'; + + export default class Demo extends Component { + @cached + get foo() { + return 'boop'; + } + } + `, + 'demo.hbs': `{{this.foo}}`, + }, + }, + tests: { + rendering: { + 'demo-test.js': ` + + import { module, test } from 'qunit'; + import { render } from '@ember/test-helpers'; + import { setupRenderingTest } from 'ember-qunit'; + import { hbs } from 'ember-cli-htmlbars'; + + module('', function(hooks) { + setupRenderingTest(hooks); + + test(\`doesn't error\`, async function(assert) { + await render(hbs\`\`); + + assert.dom().hasText('boop'); + }); + }); + `, + }, + }, + }); + }) + .forEachScenario(scenario => { + Qmodule(scenario.name, function (hooks) { + let app: PreparedApp; + hooks.before(async () => { + app = await scenario.prepare(); + }); + + test(`yarn test`, async function (assert) { + let result = await app.execute('yarn test'); + assert.equal(result.exitCode, 0, result.output); + }); + }); + });