forked from vueschool/javascript-testing-fundamentals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson3.js
51 lines (40 loc) · 1.07 KB
/
lesson3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Potential User Class that requires testing
class User {
constructor(details) {
const { firstname, lastname } = details
this.firstname = firstname
this.lastname = lastname
}
get name() {
return `${this.firstname} ${this.lastname}`
}
}
// Plain JavaScript function used for testing
const nameTest = function () {
// Define a user Object
const userDetails = {
firstname: 'Jane',
lastname: 'Doe'
}
// Instantiate a new User
const testUser = new User(userDetails)
// Print out result of the test
console.log('Username is correct: ', testUser.name === 'Jane sssDoe')
}
// Execute the test
nameTest()
// A real world user test flow could look like this
// test('user signs up and changes email', () => {
// 1. Signup using the form
// - Fill out form fields and submit
// 2. Navigate to settings
// - Find correct navigation elements
// 3. Change Value for Email
// - Find email field
// - Update Value
// - Submit Form
// Check Value is correct
// 4. Signout
// - Find Singout option
// - Verify Singout worked
// })