open-vault/ui/tests/integration/helpers/loose-equal-test.js
hc-github-team-secure-vault-core 07ca320b6d
backport of commit e32cf520f43c2708a7f6833f86d4fc0bd5620b00 (#20920)
Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
2023-06-01 18:29:12 +00:00

35 lines
1.2 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { looseEqual } from 'core/helpers/loose-equal';
module('Integration | Helper | loose-equal', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
this.inputValue = 1234;
await render(hbs`{{if (loose-equal "1234" 1234) "true" "false"}}`);
assert.dom(this.element).hasText('true');
this.inputValue = '4567';
await render(hbs`{{if (loose-equal "1234" "4567") "true" "false"}}`);
assert.dom(this.element).hasText('false');
});
test('it compares values as expected', async function (assert) {
assert.true(looseEqual([0, '0']));
assert.true(looseEqual([0, 0]));
assert.true(looseEqual(['0', '0']));
assert.true(looseEqual(['1234', 1234]));
assert.true(looseEqual(['1234', '1234']));
assert.true(looseEqual([1234, 1234]));
assert.true(looseEqual(['abc', 'abc']));
assert.true(looseEqual(['', '']));
// == normally returns true for this comparison, we intercept and return false
assert.false(looseEqual(['', 0]));
assert.false(looseEqual([0, '']));
});
});