Skip to content
Prev Previous commit
Next Next commit
added tests, used constant on replace function
  • Loading branch information
MaggieCabrera committed Feb 22, 2021
commit e19a1245712411005532894846a9aa5682a5cbcd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ color: red;
}"
`;

exports[`CSS selector wrap should replace :root selectors 1`] = `
".my-namespace {
--my-color: #ff0000;
}"
`;

exports[`CSS selector wrap should replace add editor classes to buttons 1`] = `
".my-namespace button:not(.components-button) {
background-color: #ff0000;
}"
`;

exports[`CSS selector wrap should replace add editor classes to inputs 1`] = `
".my-namespace input:not(.components-text-control__input):not(.components-placeholder__input):not(.components-form-token-field__input) {
border-color: #ff0000;
}"
`;

exports[`CSS selector wrap should replace root tags 1`] = `
".my-namespace,
.my-namespace h1 {
Expand All @@ -41,9 +59,3 @@ exports[`CSS selector wrap should wrap regular selectors 1`] = `
color: red;
}"
`;

exports[`CSS selector wrap should replace :root selectors 1`] = `
".my-namespace {
--my-color: #ff0000;
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,26 @@ describe( 'CSS selector wrap', () => {

expect( output ).toMatchSnapshot();
} );

it( 'should replace add editor classes to buttons', () => {
const callback = wrap( '.my-namespace' );
const input = `
button {
background-color: #ff0000;
}`;
const output = traverse( input, callback );

expect( output ).toMatchSnapshot();
} );

it( 'should replace add editor classes to inputs', () => {
const callback = wrap( '.my-namespace' );
const input = `
input {
border-color: #ff0000;
}`;
const output = traverse( input, callback );

expect( output ).toMatchSnapshot();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const wrap = ( namespace, ignore = [] ) => ( node ) => {
namespace +
' ' +
selector.replace(
/^(button)/,
IS_BUTTON_TAG,
'button:not(.components-button)'
)
);
Expand All @@ -32,7 +32,7 @@ const wrap = ( namespace, ignore = [] ) => ( node ) => {
namespace +
' ' +
selector.replace(
/^(input)/,
IS_INPUT_TAG,
'input:not(.components-text-control__input):not(.components-placeholder__input):not(.components-form-token-field__input)'
)
);
Expand Down