forked from facebookarchive/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp-flowtest.js
52 lines (45 loc) · 1.43 KB
/
App-flowtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';
// This file will violate certain parts of flow definitions and expect errors
// using the annotation "FlowExpectedError". This works because if the error
// suppressing comment no longer suppresses an error that becomes a flow error.
// This means regressions where we expect an error and there is not an error
// will be caught.
import AppDispatcher from '../AppDispatcher';
import AppStore from '../AppStore';
import React from 'react';
import {Container} from 'flux/utils';
/**
* Tests a simple dispatch with an invalid payload.
*/
function t1() {
// $FlowExpectedError: Cannot dispatch an incorrectly formed action.
AppDispatcher.dispatch({
type: 'foo',
bar: 'Hello Bar!',
});
}
/**
* Tests creating a container with state that doesn't match props of the view.
*/
function t2(): React.Element<*> {
function MyView(props: {value: string}) {
return <div>{props.value}</div>;
}
const MyContainer = Container.createFunctional(
MyView,
() => [AppStore],
// $FlowExpectedError: Incorrect shape for state.
() => ({notValue: AppStore.getState()}),
);
return <MyContainer />
}