Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81159 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @emails react-core
10
*/
11
12
"use strict";
13
14
/*jshint evil:true */
15
16
describe('LinkedStateMixin', function() {
17
var LinkedStateMixin;
18
var React;
19
var ReactLink;
20
21
beforeEach(function() {
22
LinkedStateMixin = require('LinkedStateMixin');
23
React = require('React');
24
ReactLink = require('ReactLink');
25
});
26
27
it('should create a ReactLink for state', function() {
28
var Component = React.createClass({
29
mixins: [LinkedStateMixin],
30
31
getInitialState: function() {
32
return {value: 'initial value'};
33
},
34
35
render: function() {
36
return <span>value is {this.state.value}</span>;
37
}
38
});
39
var container = document.createElement('div');
40
var component = React.render(<Component />, container);
41
var link = component.linkState('value');
42
expect(component.state.value).toBe('initial value');
43
expect(link.value).toBe('initial value');
44
link.requestChange('new value');
45
expect(component.state.value).toBe('new value');
46
expect(component.linkState('value').value).toBe('new value');
47
});
48
});
49
50