mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-17 12:19:12 +08:00
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @emails oncall+react_native
|
|
*/
|
|
'use strict';
|
|
|
|
var flattenStyle = require('flattenStyle');
|
|
|
|
describe('flattenStyle', () => {
|
|
|
|
it('should merge style objects', () => {
|
|
var style1 = {width: 10};
|
|
var style2 = {height: 20};
|
|
var flatStyle = flattenStyle([style1, style2]);
|
|
expect(flatStyle.width).toBe(10);
|
|
expect(flatStyle.height).toBe(20);
|
|
});
|
|
|
|
it('should override style properties', () => {
|
|
var style1 = {backgroundColor: '#000', width: 10};
|
|
var style2 = {backgroundColor: '#023c69', width: null};
|
|
var flatStyle = flattenStyle([style1, style2]);
|
|
expect(flatStyle.backgroundColor).toBe('#023c69');
|
|
expect(flatStyle.width).toBe(null);
|
|
});
|
|
|
|
it('should overwrite properties with `undefined`', () => {
|
|
var style1 = {backgroundColor: '#000'};
|
|
var style2 = {backgroundColor: undefined};
|
|
var flatStyle = flattenStyle([style1, style2]);
|
|
expect(flatStyle.backgroundColor).toBe(undefined);
|
|
});
|
|
|
|
it('should not fail on falsy values', () => {
|
|
expect(() => flattenStyle([null, false, undefined])).not.toThrow();
|
|
});
|
|
|
|
it('should recursively flatten arrays', () => {
|
|
var style1 = {width: 10};
|
|
var style2 = {height: 20};
|
|
var style3 = {width: 30};
|
|
var flatStyle = flattenStyle([null, [], [style1, style2], style3]);
|
|
expect(flatStyle.width).toBe(30);
|
|
expect(flatStyle.height).toBe(20);
|
|
});
|
|
});
|