|
1 | 1 | import { module, test } from "qunit";
|
2 | 2 | import { setupRenderingTest } from "ember-qunit";
|
3 |
| -import { render } from "@ember/test-helpers"; |
| 3 | +import { |
| 4 | + click, |
| 5 | + render, |
| 6 | + triggerKeyEvent, |
| 7 | + pauseTest, |
| 8 | + triggerEvent, |
| 9 | + find |
| 10 | +} from "@ember/test-helpers"; |
4 | 11 | import { hbs } from "ember-cli-htmlbars";
|
5 | 12 | import Service from "@ember/service";
|
6 | 13 | import { clickTrigger } from "ember-power-select/test-support/helpers";
|
7 | 14 | import { selectChoose } from "ember-power-select/test-support";
|
8 | 15 | import { setLocale } from "ember-intl/test-support";
|
| 16 | +import { scrollTo } from "@ember/test-helpers"; |
9 | 17 |
|
10 | 18 | const navServiceStub = Service.extend({
|
11 | 19 | /* eslint-disable ember/avoid-leaking-state-in-ember-objects */
|
@@ -295,4 +303,58 @@ module("Integration | Component | encryptable/form", function (hooks) {
|
295 | 303 | assert.ok(this.element.textContent.trim().includes("supporting"));
|
296 | 304 | assert.ok(this.element.textContent.trim().includes("bbt"));
|
297 | 305 | });
|
| 306 | + |
| 307 | + test("generates a 14 digit password per default", async function (assert) { |
| 308 | + await render(hbs`<Encryptable::Form />`); |
| 309 | + |
| 310 | + assert.equal( |
| 311 | + this.element.querySelector("input[name='cleartextPassword']").value |
| 312 | + .length, |
| 313 | + 14 |
| 314 | + ); |
| 315 | + }); |
| 316 | + |
| 317 | + test("Symbols are enabled per default", async function (assert) { |
| 318 | + await render(hbs`<Encryptable::Form />`); |
| 319 | + assert.equal(this.element.querySelector("input#withSymbols").checked, true); |
| 320 | + }); |
| 321 | + |
| 322 | + test("Password does not contain symbols after unchecking checkbox", async function (assert) { |
| 323 | + await render(hbs`<Encryptable::Form />`); |
| 324 | + await click("input#withSymbols"); |
| 325 | + assert.equal( |
| 326 | + this.element.querySelector("input[name='cleartextPassword']").value |
| 327 | + .length, |
| 328 | + 14 |
| 329 | + ); |
| 330 | + |
| 331 | + assert.equal( |
| 332 | + this.element.querySelector("input#withSymbols").checked, |
| 333 | + false |
| 334 | + ); |
| 335 | + assert.notOk( |
| 336 | + this.element.querySelector("input#withSymbols").value.match(/[^\w\s]/) |
| 337 | + ); |
| 338 | + }); |
| 339 | + |
| 340 | + //Last test to fix |
| 341 | + //The function in called correctly but the value passwordLength isnt updated |
| 342 | + test("Password with the right length should be generated", async function (assert) { |
| 343 | + await render(hbs`<Encryptable::Form />`); |
| 344 | + const slider = this.element.querySelector("input#formControlRange"); |
| 345 | + slider.value = 17; |
| 346 | + await triggerEvent(slider, "change"); |
| 347 | + await triggerEvent(slider, "input"); |
| 348 | + await pauseTest(); |
| 349 | + console.log(slider.value); |
| 350 | + assert.equal( |
| 351 | + this.element.querySelector("input[name='cleartextPassword']").value |
| 352 | + .length, |
| 353 | + 17 |
| 354 | + ); |
| 355 | + await click("input#withSymbols"); |
| 356 | + assert.notOk( |
| 357 | + this.element.querySelector("input#withSymbols").value.match(/[^\w\s]/) |
| 358 | + ); |
| 359 | + }); |
298 | 360 | });
|
0 commit comments