|
1 | | -const chance = require('chance')(); |
| 1 | +const chance = require("chance")(); |
2 | 2 |
|
3 | | -describe('Register', function () { |
4 | | - const username = `${chance.first()}${chance.first()}${chance.last()}`; |
5 | | - const email = `${username}@mail.com`; |
6 | | - it('register an account', function (client) { |
7 | | - client.page.register().navigate() |
8 | | - .waitForElementVisible('.register-form', 5000) |
9 | | - .setValue('@emailInput', email) |
10 | | - .setValue('@usernameInput', username) |
11 | | - .setValue('@passwordInput', 'password') |
12 | | - .click('@submit') |
13 | | - .waitForElementVisible('.registration-request-complete', 5000) |
14 | | - }); |
15 | | - it('register an account with the same username', function (client) { |
| 3 | +describe("Register", function () { |
| 4 | + const username = `${chance.first()}${chance.first()}${chance.last()}`; |
| 5 | + const email = `${username}@mail.com`; |
| 6 | + it("register an account", function (client) { |
| 7 | + client.page |
| 8 | + .register() |
| 9 | + .navigate() |
| 10 | + .waitForElementVisible(".register-form", 5000) |
| 11 | + .setValue("@emailInput", email) |
| 12 | + .setValue("@usernameInput", username) |
| 13 | + .setValue("@passwordInput", "password") |
| 14 | + .click("@submit") |
| 15 | + .waitForElementVisible(".registration-request-complete", 5000); |
| 16 | + }); |
| 17 | + it("register an account with the same username", function (client) { |
| 18 | + client.page |
| 19 | + .register() |
| 20 | + .navigate() |
| 21 | + .waitForElementVisible(".register-form", 5000) |
| 22 | + .setValue("@emailInput", "alice@mail.com") |
| 23 | + .setValue("@usernameInput", "alice") |
| 24 | + .setValue("@passwordInput", "password") |
| 25 | + .click("@submit") |
| 26 | + .waitForElementVisible(".register-error-view", 5000); |
16 | 27 |
|
17 | | - client.page.register().navigate() |
18 | | - .waitForElementVisible('.register-form', 5000) |
19 | | - .setValue('@emailInput', "alice@mail.com") |
20 | | - .setValue('@usernameInput', "alice") |
21 | | - .setValue('@passwordInput', 'password') |
22 | | - .click('@submit') |
23 | | - .waitForElementVisible('.register-error-view', 5000) |
| 28 | + client.assert.containsText( |
| 29 | + ".register-form", |
| 30 | + "The username is already used" |
| 31 | + ); |
| 32 | + }); |
| 33 | + it("missing username", function (client) { |
| 34 | + client.page |
| 35 | + .register() |
| 36 | + .navigate() |
| 37 | + .waitForElementVisible(".register-form", 5000) |
| 38 | + .setValue("@emailInput", "alice@mail.com") |
| 39 | + .setValue("@passwordInput", "password") |
| 40 | + .click("@submit"); |
24 | 41 |
|
25 | | - client.assert.containsText('.register-form', 'The username is already used') |
26 | | - }); |
27 | | - it('missing username', function (client) { |
28 | | - client.page.register().navigate() |
29 | | - .waitForElementVisible('.register-form', 5000) |
30 | | - .setValue('@emailInput', 'alice@mail.com') |
31 | | - .setValue('@passwordInput', 'password') |
32 | | - .click('@submit'); |
| 42 | + client.assert.containsText( |
| 43 | + ".register-form", |
| 44 | + "Username must be at least 2 characters" |
| 45 | + ); |
| 46 | + }); |
| 47 | + it("missing email", function (client) { |
| 48 | + client.page |
| 49 | + .register() |
| 50 | + .navigate() |
| 51 | + .waitForElementVisible(".register-form", 5000) |
| 52 | + .setValue("@usernameInput", "alice") |
| 53 | + .setValue("@passwordInput", "password") |
| 54 | + .click("@submit"); |
33 | 55 |
|
34 | | - client.assert.containsText('.register-form', 'Username must be at least 3 characters') |
35 | | - }); |
36 | | - it('missing email', function (client) { |
37 | | - client.page.register().navigate() |
38 | | - .waitForElementVisible('.register-form', 5000) |
39 | | - .setValue('@usernameInput', 'alice') |
40 | | - .setValue('@passwordInput', 'password') |
41 | | - .click('@submit'); |
| 56 | + client.assert.containsText(".register-form", "Email is not a valid email"); |
| 57 | + }); |
| 58 | + it("missing password", function (client) { |
| 59 | + client.page |
| 60 | + .register() |
| 61 | + .navigate() |
| 62 | + .waitForElementVisible(".register-form", 5000) |
| 63 | + .setValue("@usernameInput", "alice") |
| 64 | + .setValue("@emailInput", "alice@mail.com") |
| 65 | + .click("@submit"); |
42 | 66 |
|
43 | | - client.assert.containsText('.register-form', 'Email is not a valid email') |
44 | | - }); |
45 | | - it('missing password', function (client) { |
46 | | - client.page.register().navigate() |
47 | | - .waitForElementVisible('.register-form', 5000) |
48 | | - .setValue('@usernameInput', 'alice') |
49 | | - .setValue('@emailInput', 'alice@mail.com') |
50 | | - .click('@submit'); |
51 | | - |
52 | | - client.assert.containsText('.register-form', 'Password must be at least 6 characters') |
53 | | - }); |
| 67 | + client.assert.containsText( |
| 68 | + ".register-form", |
| 69 | + "Password must be at least 6 characters" |
| 70 | + ); |
| 71 | + }); |
54 | 72 | }); |
0 commit comments