decide.nolog.cz/tests/helpers/poll-has-user.js
renovate[bot] 98ff62af80
Update dependency prettier to v3 (#668)
* Update dependency prettier to v3

* upgrade eslint-plugin-prettier and run prettier on all files

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jeldrik Hanschke <admin@jhanschke.de>
2023-10-17 10:44:45 +02:00

29 lines
823 B
JavaScript

import { isEmpty } from '@ember/utils';
import { findAll } from '@ember/test-helpers';
function pollHasUser(assert, name, selections) {
let elBase = findAll('.user').find((el) => {
return el.querySelector('td:nth-child(1)').textContent.trim() === name;
});
assert.ok(elBase, `user ${name} exists`);
if (elBase) {
selections.forEach((selection, index) => {
assert.equal(
elBase.querySelector(`td:nth-child(${index + 2})`).textContent.trim(),
selection.toString(),
`selection ${index} is as expected`,
);
});
}
}
function pollHasUsersCount(assert, count, message) {
if (isEmpty(message)) {
message = 'poll has expected count of users';
}
assert.equal(findAll('.user').length, count, message);
}
export default pollHasUser;
export { pollHasUsersCount };