@@ -11,73 +11,70 @@ describe('Hierarchical dependency injection', () => {
11
11
describe ( 'Heroes Scenario' , ( ) => {
12
12
let page = {
13
13
heroName : '' ,
14
- heroText : '' ,
14
+ income : '' ,
15
15
16
16
// queries
17
17
heroEl : element . all ( by . css ( 'heroes-list li' ) ) . get ( 0 ) , // first hero
18
- heroCardEl : element ( by . css ( 'heroes-list hero-card' ) ) , // first hero card
19
- cardNameInputEl : element . all ( by . css ( 'heroes-list hero-card input' ) ) . get ( 0 ) ,
20
- cancelButtonEl : element ( by . cssContainingText ( 'heroes-list hero-card button' , 'Cancel' ) ) ,
21
- closeButtonEl : element ( by . cssContainingText ( 'heroes-list hero-card button' , 'Close' ) ) ,
22
- saveButtonEl : element ( by . cssContainingText ( 'heroes-list hero-card button' , 'Save' ) )
18
+ heroCardEl : element ( by . css ( 'heroes-list hero-tax-return' ) ) , // first hero tax-return
19
+ taxReturnNameEl : element . all ( by . css ( 'heroes-list hero-tax-return #name' ) ) . get ( 0 ) ,
20
+ incomeInputEl : element . all ( by . css ( 'heroes-list hero-tax-return input' ) ) . get ( 0 ) ,
21
+ cancelButtonEl : element ( by . cssContainingText ( 'heroes-list hero-tax-return button' , 'Cancel' ) ) ,
22
+ closeButtonEl : element ( by . cssContainingText ( 'heroes-list hero-tax-return button' , 'Close' ) ) ,
23
+ saveButtonEl : element ( by . cssContainingText ( 'heroes-list hero-tax-return button' , 'Save' ) )
23
24
} ;
24
25
25
26
it ( 'should list multiple heroes' , ( ) => {
26
27
expect ( element . all ( by . css ( 'heroes-list li' ) ) . count ( ) ) . toBeGreaterThan ( 1 ) ;
27
28
} ) ;
28
29
29
- it ( 'should show no hero cards at the start' , ( ) => {
30
- expect ( element . all ( by . css ( 'heroes-list li hero-card ' ) ) . count ( ) ) . toBe ( 0 ) ;
30
+ it ( 'should show no hero tax-returns at the start' , ( ) => {
31
+ expect ( element . all ( by . css ( 'heroes-list li hero-tax-return ' ) ) . count ( ) ) . toBe ( 0 ) ;
31
32
} ) ;
32
33
33
- it ( 'should open first hero in hero-card view after click' , ( ) => {
34
+ it ( 'should open first hero in hero-tax-return view after click' , ( ) => {
34
35
page . heroEl . getText ( )
35
36
. then ( val => {
36
- // console.log('Selected hero text: ' + val);
37
- page . heroText = val ;
38
- page . heroName = val . substring ( 0 , val . indexOf ( '()' ) - 1 ) ;
37
+ page . heroName = val ;
39
38
} )
40
39
. then ( ( ) => page . heroEl . click ( ) )
41
40
. then ( ( ) => {
42
41
expect ( page . heroCardEl . isDisplayed ( ) ) . toBe ( true ) ;
43
42
} ) ;
44
43
} ) ;
45
44
46
- it ( 'hero card should have first hero\'s name' , ( ) => {
47
- // Not `page.cardNameInputEl .getAttribute('value')` although later that is essential
48
- expect ( page . cardNameInputEl . getText ( ) ) . toEqual ( page . heroName ) ;
45
+ it ( 'hero tax-return should have first hero\'s name' , ( ) => {
46
+ // Not `page.tax-returnNameInputEl .getAttribute('value')` although later that is essential
47
+ expect ( page . taxReturnNameEl . getText ( ) ) . toEqual ( page . heroName ) ;
49
48
} ) ;
50
49
51
50
it ( 'should be able to cancel change' , ( ) => {
52
- page . cardNameInputEl . sendKeys ( 'foo' )
51
+ page . incomeInputEl . clear ( )
52
+ . then ( ( ) => page . incomeInputEl . sendKeys ( '777' ) )
53
53
. then ( ( ) => {
54
- expect ( page . cardNameInputEl . getAttribute ( 'value' ) ) . toContain ( 'foo' , 'input name should have foo' ) ;
55
- expect ( page . heroEl . getText ( ) ) . toEqual ( page . heroText , 'list text should be unchanged' ) ;
54
+ expect ( page . incomeInputEl . getAttribute ( 'value' ) ) . toBe ( '777' , 'income should be 777' ) ;
56
55
return page . cancelButtonEl . click ( ) ;
57
56
} )
58
57
. then ( ( ) => {
59
- expect ( page . cardNameInputEl . getAttribute ( 'value' ) ) . not . toContain ( 'foo' , 'input name should not have foo' ) ;
60
- expect ( page . heroEl . getText ( ) ) . toEqual ( page . heroText , 'list text should be unchanged' ) ;
58
+ expect ( page . incomeInputEl . getAttribute ( 'value' ) ) . not . toBe ( '777' , 'income should not be 777' ) ;
61
59
} ) ;
62
60
} ) ;
63
61
64
62
it ( 'should be able to save change' , ( ) => {
65
- page . cardNameInputEl . sendKeys ( 'bar' )
63
+ page . incomeInputEl . clear ( )
64
+ . then ( ( ) => page . incomeInputEl . sendKeys ( '999' ) )
66
65
. then ( ( ) => {
67
- expect ( page . cardNameInputEl . getAttribute ( 'value' ) ) . toContain ( 'bar' , 'input name should have bar' ) ;
68
- expect ( page . heroEl . getText ( ) ) . toEqual ( page . heroText , 'list text should be unchanged' ) ;
66
+ expect ( page . incomeInputEl . getAttribute ( 'value' ) ) . toBe ( '999' , 'income should be 999' ) ;
69
67
return page . saveButtonEl . click ( ) ;
70
68
} )
71
69
. then ( ( ) => {
72
- expect ( page . cardNameInputEl . getAttribute ( 'value' ) ) . toContain ( 'bar' , 'input name should still have bar' ) ;
73
- expect ( page . heroEl . getText ( ) ) . toContain ( 'bar' , 'list text should have changed to include bar' ) ;
70
+ expect ( page . incomeInputEl . getAttribute ( 'value' ) ) . toBe ( '999' , 'income should still be 999' ) ;
74
71
} ) ;
75
72
} ) ;
76
73
77
- it ( 'should be able to close card ' , ( ) => {
74
+ it ( 'should be able to close tax-return ' , ( ) => {
78
75
page . saveButtonEl . click ( )
79
76
. then ( ( ) => {
80
- expect ( element . all ( by . css ( 'heroes-list li hero-card ' ) ) . count ( ) ) . toBe ( 0 ) ;
77
+ expect ( element . all ( by . css ( 'heroes-list li hero-tax-return ' ) ) . count ( ) ) . toBe ( 0 ) ;
81
78
} ) ;
82
79
} ) ;
83
80
0 commit comments