Files

37 lines
1019 B
Plaintext

import { module, test } from 'qunit';
import { setupRenderingTest } from 'dashtab/tests/helpers';
import { render } from '@ember/test-helpers';
import setStyle from 'dashtab/modifiers/set-style';
module('Integration | Modifier | set-style', function (hooks) {
setupRenderingTest(hooks);
test('it sets a CSS property', async function (assert) {
this.set('color', '#ff0000');
await render(
<template>
<div data-test-target {{setStyle "background-color" this.color}}></div>
</template>
);
assert
.dom('[data-test-target]')
.hasAttribute('style', /background-color:\s*rgb\(255, 0, 0\)/);
});
test('it removes the property when the value is empty', async function (assert) {
this.set('color', undefined);
await render(
<template>
<div data-test-target {{setStyle "background-color" this.color}}></div>
</template>
);
assert
.dom('[data-test-target]')
.doesNotHaveAttribute('style', /background-color/);
});
});