forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of github.com:amitraj2203/gutenberg into fix/iss…
…ue-61931
- Loading branch information
Showing
15 changed files
with
126 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './components'; | ||
import './validate-multiple-use'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/edit-site/src/components/global-styles/test/utils.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getNewIndexFromPresets } from '../utils'; | ||
|
||
const validPresets = { | ||
single: [ { slug: 'preset-1' } ], | ||
multiple: [ { slug: 'preset-1' }, { slug: 'preset-2' } ], | ||
withGaps: [ { slug: 'preset-1' }, { slug: 'preset-3' } ], | ||
mixedPrefixes: [ | ||
{ slug: 'preset-1' }, | ||
{ slug: 'shadow-2' }, | ||
{ slug: 'preset-3' }, | ||
], | ||
nonStringSlug: [ { slug: 'preset-1' }, { slug: 2 } ], | ||
emptyArray: [], | ||
}; | ||
|
||
const invalidPresets = { | ||
noMatch: [ { slug: 'preset-alpha' }, { slug: 'preset-beta' } ], | ||
emptySlug: [ { slug: '' } ], | ||
nullSlug: [ { slug: null } ], | ||
undefinedSlug: [ { slug: undefined } ], | ||
nonObjectElements: [ 'preset-1' ], | ||
}; | ||
|
||
const getExpectedIndex = ( presetKey, presets ) => { | ||
if ( presetKey === 'withGaps' ) { | ||
return 4; | ||
} | ||
if ( presetKey === 'mixedPrefixes' ) { | ||
return 4; | ||
} | ||
if ( presetKey === 'nonStringSlug' ) { | ||
return 2; | ||
} | ||
return presets.length + 1; | ||
}; | ||
|
||
describe( 'getNewIndexFromPresets', () => { | ||
Object.entries( validPresets ).forEach( ( [ presetKey, presets ] ) => { | ||
describe( `test valid preset format: ${ presetKey }`, () => { | ||
const newIndex = getNewIndexFromPresets( presets, 'preset-' ); | ||
it( `should return correct new index for ${ presetKey }`, () => { | ||
const expectedIndex = getExpectedIndex( presetKey, presets ); | ||
expect( newIndex ).toBe( expectedIndex ); | ||
} ); | ||
} ); | ||
} ); | ||
|
||
Object.entries( invalidPresets ).forEach( ( [ presetKey, presets ] ) => { | ||
describe( `test invalid preset format: ${ presetKey }`, () => { | ||
const newIndex = getNewIndexFromPresets( presets, 'preset-' ); | ||
it( `should return 1 for ${ presetKey }`, () => { | ||
expect( newIndex ).toBe( 1 ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import './components'; | ||
import './push-changes-to-global-styles'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters