forked from aweary/react-is-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
45 lines (43 loc) · 2.01 KB
/
test.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
'use strict'
var expect = require('chai').expect;
var React = require('react');
var LegacyPropTypes = require('react').PropTypes;
var addIsDeprecated = require('./dist').addIsDeprecated;
var deprecate = require('./dist').deprecate;
var PropTypes = require('prop-types');
describe('react-is-deprecated', () => {
it('should export an `addIsDeprecated` function', () => {
expect(addIsDeprecated).to.be.a('function')
})
it('should export an `deprecate` function', () => {
expect(deprecate).to.be.a('function')
})
describe('with legacy React.Proptypes object', () => {
Object.freeze(LegacyPropTypes)
it('should not mutate the React PropTypes API', () => {
let initialObjectType = LegacyPropTypes.object
const NewPropTypes = addIsDeprecated(LegacyPropTypes)
expect(LegacyPropTypes.object.isDeprecated).to.equal(undefined)
expect(LegacyPropTypes.object === initialObjectType).to.equal(true)
})
console.log('PropTypes before tests', LegacyPropTypes.object.isDeprecated);
it('should add an isDeprecated method to the passed PropTypes.', () => {
const NewPropTypes = addIsDeprecated(LegacyPropTypes)
expect(NewPropTypes.object.isDeprecated).to.be.a('function')
})
})
describe('with external prop-types library', () => {
Object.freeze(PropTypes)
it('should not mutate the React PropTypes API', () => {
let initialObjectType = PropTypes.object
const NewPropTypes = addIsDeprecated(PropTypes)
expect(PropTypes.object.isDeprecated).to.equal(undefined)
expect(PropTypes.object === initialObjectType).to.equal(true)
})
console.log('PropTypes before tests', PropTypes.object.isDeprecated);
it('should add an isDeprecated method to the passed PropTypes.', () => {
const NewPropTypes = addIsDeprecated(PropTypes)
expect(NewPropTypes.object.isDeprecated).to.be.a('function')
})
})
})