feat(platform-server): add an API to transfer state from server (#19134)
TransferState provides a shared store that is transferred from the server to client. To use it import BrowserTransferStateModule from the client app module and ServerTransferStateModule from the server app module and TransferState will be available as an Injectable object. PR Close #19134
This commit is contained in:

committed by
Igor Minar

parent
f96142cd7c
commit
cfd9ca0d6f
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {browser, by, element} from 'protractor';
|
||||
|
||||
import {verifyNoBrowserErrors} from './util';
|
||||
|
||||
describe('TransferState', function() {
|
||||
it('should transfer component state', function() {
|
||||
// Load the page without waiting for Angular since it is not boostrapped automatically.
|
||||
browser.driver.get(browser.baseUrl + 'transferstate');
|
||||
|
||||
// Test the contents from the server.
|
||||
const serverDiv = browser.driver.findElement(by.css('div'));
|
||||
expect(serverDiv.getText()).toEqual('5');
|
||||
|
||||
// Bootstrap the client side app and retest the contents
|
||||
browser.executeScript('doBootstrap()');
|
||||
expect(element(by.css('div')).getText()).toEqual('50');
|
||||
|
||||
// Make sure there were no client side errors.
|
||||
verifyNoBrowserErrors();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user