Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mobile] Add unit tests for willTrimSpaces function in RichText #15552

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default class RCTAztecView {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export class View {};
export class Platform {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Internal dependencies
*/
import { RichText } from '../index.native';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imported from ../index.native because I was originally using this within the gutenberg test pipeline (without altering the jest config). I'm unsure whether this will be necessary if we plan to introduce a separate mobile-specific jest configuration which resolves all *.native.js files to their *.js key-names in the dependency map. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running with gutenberg-mobile tooling, importing ../index will be enough 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @etoledom ! Fixed ✔️


describe( 'RichText Native', () => {
let richText;

beforeEach( () => {
richText = new RichText( { multiline: false } );
} );

it ( 'exists', () => {
expect( richText );
} );

describe( 'willTrimSpaces', () => {
it( 'exists', () => {
expect( richText.willTrimSpaces );
} );

it( 'is a function', () => {
expect( typeof richText.willTrimSpaces === 'function' );
} );

it( 'reports false for styled text with no outer spaces', () => {
let html = '<p><b>Hello</b> <strong>Hello</strong> WorldWorld!</p>';
expect( richText.willTrimSpaces( html ) ).toBe( false );
} );
} );
} );
2 changes: 1 addition & 1 deletion test/unit/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ module.exports = {
'/packages/e2e-tests',
'<rootDir>/.*/build/',
'<rootDir>/.*/build-module/',
'.*.native.js',
'<rootDir>/.+\.native\.js$',
mkevins marked this conversation as resolved.
Show resolved Hide resolved
],
};