1
2class Arithmetic {
3 constructor() {
4 this.value = 0;
5 }
6 sum(...args) {
7 this.value = args.reduce((sum, current) => sum + current, 0);
8 return this;
9 }
10 add(value) {
11 this.value = this.value + value;
12 return this;
13 }
14 subtract(value) {
15 this.value = this.value - value;
16 return this;
17 }
18 average(...args) {
19 this.value = args.length
20 ? (this.sum(...args).value) / args.length
21 : undefined;
22 return this;
23 }
24}
25
26a = new Arithmetic()
27a.sum(1, 3, 6) // => { value: 10 }
28 .subtract(3) // => { value: 7 }
29 .add(4) // => { value: 11 }
30 .value // => 11
31
32// Console Output
33// 11
1String methods can be combined in a process called method chaining.
2Given word = 'JavaScript';, word.toUpperCase() returns JAVASCRIPT.
3What would word.slice(4).toUpperCase() return?
4
1given() .... --> RequestSpecification
2 .header accept() contentType()
3 .queryParam
4 .pathParam
5 .body
6 .log
7 .auth..
8when() --->> RequestSender
9 .get() ------>> Response Object
10 .post()
11 .put()
12 .delete()
13then() -----> ValidatableResponse
14 This is where assertion happen
15 .statusCode
16 .header accept() contentType()
17 .body( matchers goes here)
18 .log
19