-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathclass-names-test.gts
39 lines (31 loc) · 1.18 KB
/
class-names-test.gts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { settled, render } from '@ember/test-helpers';
import { tracked } from '@glimmer/tracking';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
import { cn } from '@appuniversum/ember-appuniversum/private/helpers/class-names';
module('Integration | Private Helper | class-names', function (hooks) {
setupRenderingTest(hooks);
test('it accepts a list of classes and adds the needed whitespace', async function (assert) {
await render(
<template>
<div data-test class={{cn "foo" "bar" "baz"}}></div>
</template>,
);
assert.dom('[data-test]').hasClass('foo').hasClass('bar').hasClass('baz');
});
test('it removes falsy values', async function (assert) {
class TestState {
@tracked someFlag: boolean = false;
}
const state = new TestState();
await render(
<template>
<div data-test class={{cn "foo" (if state.someFlag "bar") "baz"}}></div>
</template>,
);
assert.dom('[data-test]').hasClass('foo').hasNoClass('bar').hasClass('baz');
state.someFlag = true;
await settled();
assert.dom('[data-test]').hasClass('foo').hasClass('bar').hasClass('baz');
});
});