Skip to content

Commit

Permalink
Remove more
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 9, 2024
1 parent 925a113 commit d59b704
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 83 deletions.
7 changes: 1 addition & 6 deletions test-app/app/components/glint-colocated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@ import { tracked } from '@glimmer/tracking';

import { resource, use } from 'ember-resources';

import { Calculator, clock, Doubler, overInvalidatingClock } from './-resources';
import { clock, overInvalidatingClock } from './-resources';

export default class GlintTest extends Component {
@tracked input = 2;

Calculator = Calculator;
Doubler = Doubler;
clock = clock;
overInvalidatingClock = overInvalidatingClock;

calculator = Calculator.from(this, () => ({}));
doubler = Doubler.from(this, () => [this.input]);

decoratorLess = resource(this, () => {
return 2 * this.input;
});
Expand Down
78 changes: 1 addition & 77 deletions test-app/tests/core/rendering-test.gts
Original file line number Diff line number Diff line change
@@ -1,90 +1,14 @@
import { tracked } from '@glimmer/tracking';
// @ts-ignore @ember/modifier does not provide types :(
import { on } from '@ember/modifier';
import { click, render } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';

import { cell, Resource, resource, resourceFactory, use } from 'ember-resources';
import { cell, resource, resourceFactory } from 'ember-resources';

module('Core | Resource | rendering', function (hooks) {
setupRenderingTest(hooks);

class Doubler extends Resource<{ positional: [number] }> {
@tracked num = 0;

modify(positional: [number]) {
this.num = positional[0] * 2;
}
}

module('directly in a template', function() {
test('it works', async function (assert) {
let count = cell(0);
let increment = () => count.current++;

await render(<template>
{{#let (Doubler count.current) as |doubler|}}
<out>{{doubler.num}}</out>
{{/let}}
<button type='button' {{on 'click' increment}}>increment</button>
</template>);

assert.dom('out').hasText('0');

await click('button');

assert.dom('out').hasText('2');
});
});

module('in a class', function () {
test('it works in a class', async function (assert) {
class Test {
@tracked count = 0;

data = Doubler.from(this, () => [this.count]);
increment = () => this.count++;
}

let foo = new Test();

await render(<template>
<out>{{foo.data.num}}</out>
<button type='button' {{on 'click' foo.increment}}>increment</button>
</template>);

assert.dom('out').hasText('0');

await click('button');

assert.dom('out').hasText('2');
});

test('it works with @use', async function (assert) {
class Test {
@tracked count = 0;


@use data = Doubler.from(() => [this.count]);
increment = () => this.count++;
}

let foo = new Test();

await render(<template>
<out>{{foo.data.num}}</out>
<button type='button' {{on 'click' foo.increment}}>increment</button>
</template>);

assert.dom('out').hasText('0');

await click('button');

assert.dom('out').hasText('2');
});
});

module('cleanup with wrapping factory/blueprint', function() {
test('a generated interval can be cleared', async function (assert) {
const id = cell(0);
Expand Down

0 comments on commit d59b704

Please sign in to comment.