|
1 |
| -describe('async angular2 application', function() { |
2 |
| - var URL = '/ng2/#/async'; |
| 1 | +describe('async angular2 application', () => { |
| 2 | + const URL = '/ng2/#/async'; |
3 | 3 |
|
4 |
| - beforeEach(function() { |
5 |
| - browser.get(URL); |
| 4 | + beforeEach(async() => { |
| 5 | + await browser.get(URL); |
6 | 6 | });
|
7 | 7 |
|
8 |
| - it('should work with synchronous actions', function() { |
9 |
| - var increment = $('#increment'); |
10 |
| - increment.$('.action').click(); |
| 8 | + it('should work with synchronous actions', async() => { |
| 9 | + const increment = $('#increment'); |
| 10 | + await increment.$('.action').click(); |
11 | 11 |
|
12 |
| - expect(increment.$('.val').getText()).toEqual('1'); |
| 12 | + expect(await increment.$('.val').getText()).toEqual('1'); |
13 | 13 | });
|
14 | 14 |
|
15 |
| - it('should wait for asynchronous actions', function() { |
16 |
| - var timeout = $('#delayedIncrement'); |
| 15 | + it('should wait for asynchronous actions', async() => { |
| 16 | + const timeout = $('#delayedIncrement'); |
17 | 17 |
|
18 | 18 | // At this point, the async action is still pending, so the count should
|
19 | 19 | // still be 0.
|
20 |
| - expect(timeout.$('.val').getText()).toEqual('0'); |
| 20 | + expect(await timeout.$('.val').getText()).toEqual('0'); |
21 | 21 |
|
22 |
| - timeout.$('.action').click(); |
| 22 | + await timeout.$('.action').click(); |
23 | 23 |
|
24 |
| - expect(timeout.$('.val').getText()).toEqual('1'); |
| 24 | + expect(await timeout.$('.val').getText()).toEqual('1'); |
25 | 25 | });
|
26 | 26 |
|
27 |
| - it('should turn off when ignoreSynchronization is true', function() { |
28 |
| - var timeout = $('#delayedIncrement'); |
| 27 | + it('should turn off when ignoreSynchronization is true', async() => { |
| 28 | + // const timeout = $('#delayedIncrement'); |
29 | 29 |
|
30 | 30 | // At this point, the async action is still pending, so the count should
|
31 | 31 | // still be 0.
|
32 |
| - expect(timeout.$('.val').getText()).toEqual('0'); |
| 32 | + expect(await $('#delayedIncrement').$('.val').getText()).toEqual('0'); |
33 | 33 |
|
34 |
| - browser.waitForAngularEnabled(false); |
| 34 | + await browser.waitForAngularEnabled(false); |
35 | 35 |
|
36 |
| - timeout.$('.action').click(); |
37 |
| - timeout.$('.cancel').click(); |
| 36 | + await $('#delayedIncrement').$('.action').click(); |
| 37 | + await $('#delayedIncrement').$('.cancel').click(); |
38 | 38 |
|
39 |
| - browser.waitForAngularEnabled(true); |
| 39 | + await browser.waitForAngularEnabled(true); |
40 | 40 |
|
41 | 41 | // whenStable should be called since the async action is cancelled. The
|
42 | 42 | // count should still be 0;
|
43 |
| - expect(timeout.$('.val').getText()).toEqual('0'); |
| 43 | + expect(await $('#delayedIncrement').$('.val').getText()).toEqual('0'); |
44 | 44 | });
|
45 | 45 |
|
46 |
| - it('should wait for a series of asynchronous actions', function() { |
47 |
| - var timeout = $('#chainedDelayedIncrements'); |
| 46 | + it('should wait for a series of asynchronous actions', async() => { |
| 47 | + const timeout = $('#chainedDelayedIncrements'); |
48 | 48 |
|
49 | 49 | // At this point, the async action is still pending, so the count should
|
50 | 50 | // still be 0.
|
51 |
| - expect(timeout.$('.val').getText()).toEqual('0'); |
| 51 | + expect(await timeout.$('.val').getText()).toEqual('0'); |
52 | 52 |
|
53 |
| - timeout.$('.action').click(); |
| 53 | + await timeout.$('.action').click(); |
54 | 54 |
|
55 |
| - expect(timeout.$('.val').getText()).toEqual('10'); |
| 55 | + expect(await timeout.$('.val').getText()).toEqual('10'); |
56 | 56 | });
|
57 | 57 |
|
58 |
| - describe('long async spec', function() { |
59 |
| - var originalTimeout; |
60 |
| - beforeEach(function() { |
| 58 | + describe('long async spec', () => { |
| 59 | + let originalTimeout; |
| 60 | + beforeEach(() => { |
61 | 61 | originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
62 | 62 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
63 | 63 | });
|
64 | 64 |
|
65 |
| - it('should wait for a series of periodic increments', function() { |
66 |
| - var timeout = $('#periodicIncrement_unzoned'); |
| 65 | + it('should wait for a series of periodic increments', async() => { |
| 66 | + const timeout = $('#periodicIncrement_unzoned'); |
67 | 67 |
|
68 | 68 | // Waits for the val to count 2.
|
69 |
| - var EC = protractor.ExpectedConditions; |
70 |
| - timeout.$('.action').click(); |
71 |
| - browser.wait(EC.textToBePresentInElement(timeout.$('.val'), '1'), 4000); |
72 |
| - timeout.$('.cancel').click(); |
73 |
| - |
74 |
| - var text = timeout.$('.val').getText(); |
75 |
| - browser.driver.sleep(3000); |
76 |
| - expect(timeout.$('.val').getText()).toEqual(text); |
| 69 | + const EC = protractor.ExpectedConditions; |
| 70 | + await timeout.$('.action').click(); |
| 71 | + await browser.wait(EC.textToBePresentInElement(timeout.$('.val'), '1'), |
| 72 | + 4000); |
| 73 | + await timeout.$('.cancel').click(); |
| 74 | + |
| 75 | + const text = timeout.$('.val').getText(); |
| 76 | + await browser.driver.sleep(3000); |
| 77 | + expect(await timeout.$('.val').getText()).toEqual(text); |
77 | 78 | });
|
78 | 79 |
|
79 |
| - afterEach(function() { |
| 80 | + afterEach(() => { |
80 | 81 | jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
81 | 82 | });
|
82 | 83 | });
|
|
0 commit comments