Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 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
require('mock-modules')
15
.dontMock('EventPluginHub')
16
.mock('isEventSupported');
17
18
describe('EventPluginHub', function() {
19
var EventPluginHub;
20
var isEventSupported;
21
22
beforeEach(function() {
23
require('mock-modules').dumpCache();
24
EventPluginHub = require('EventPluginHub');
25
isEventSupported = require('isEventSupported');
26
isEventSupported.mockReturnValueOnce(false);
27
});
28
29
it("should prevent non-function listeners", function() {
30
expect(function() {
31
EventPluginHub.putListener(1, 'onClick', 'not a function');
32
}).toThrow(
33
'Invariant Violation: Expected onClick listener to be a function, ' +
34
'instead got type string'
35
);
36
});
37
});
38
39