-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using modules in the interactivity e2e tests
- Loading branch information
1 parent
4135f22
commit 876fdb1
Showing
38 changed files
with
576 additions
and
566 deletions.
There are no files selected for viewing
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
62 changes: 32 additions & 30 deletions
62
packages/e2e-tests/plugins/interactive-blocks/directive-bind/view.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 |
---|---|---|
@@ -1,35 +1,37 @@ | ||
( ( { wp } ) => { | ||
const { store, getContext } = wp.interactivity; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { store, getContext } from '@wordpress/interactivity'; | ||
|
||
const { state, foo } = store( 'directive-bind', { | ||
state: { | ||
url: '/some-url', | ||
checked: true, | ||
show: false, | ||
width: 1, | ||
const { state, foo } = store( 'directive-bind', { | ||
state: { | ||
url: '/some-url', | ||
checked: true, | ||
show: false, | ||
width: 1, | ||
}, | ||
foo: { | ||
bar: 1, | ||
}, | ||
actions: { | ||
toggle: () => { | ||
state.url = '/some-other-url'; | ||
state.checked = ! state.checked; | ||
state.show = ! state.show; | ||
state.width += foo.bar; | ||
}, | ||
foo: { | ||
bar: 1, | ||
}, | ||
actions: { | ||
toggle: () => { | ||
state.url = '/some-other-url'; | ||
state.checked = ! state.checked; | ||
state.show = ! state.show; | ||
state.width += foo.bar; | ||
}, | ||
toggleValue: () => { | ||
const context = getContext(); | ||
const previousValue = ( 'previousValue' in context ) | ||
toggleValue: () => { | ||
const context = getContext(); | ||
const previousValue = | ||
'previousValue' in context | ||
? context.previousValue | ||
// Any string works here; we just want to toggle the value | ||
// to ensure Preact renders the same we are hydrating in the | ||
// first place. | ||
: 'tacocat'; | ||
: // Any string works here; we just want to toggle the value | ||
// to ensure Preact renders the same we are hydrating in the | ||
// first place. | ||
'tacocat'; | ||
|
||
context.previousValue = context.value; | ||
context.value = previousValue; | ||
} | ||
context.previousValue = context.value; | ||
context.value = previousValue; | ||
}, | ||
} ); | ||
} )( window ); | ||
}, | ||
} ); |
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
21 changes: 11 additions & 10 deletions
21
packages/e2e-tests/plugins/interactive-blocks/directive-body/view.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
( ( { wp } ) => { | ||
const { store, getContext } = wp.interactivity; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { store, getContext } from '@wordpress/interactivity'; | ||
|
||
store( 'directive-body', { | ||
actions: { | ||
toggleText: () => { | ||
const context = getContext(); | ||
context.text = context.text === 'text-1' ? 'text-2' : 'text-1'; | ||
}, | ||
store( 'directive-body', { | ||
actions: { | ||
toggleText: () => { | ||
const context = getContext(); | ||
context.text = context.text === 'text-1' ? 'text-2' : 'text-1'; | ||
}, | ||
} ); | ||
} )( window ); | ||
}, | ||
} ); |
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
39 changes: 20 additions & 19 deletions
39
packages/e2e-tests/plugins/interactive-blocks/directive-class/view.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 |
---|---|---|
@@ -1,22 +1,23 @@ | ||
( ( { wp } ) => { | ||
const { store, getContext } = wp.interactivity; | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { store, getContext } from '@wordpress/interactivity'; | ||
|
||
const { state } = store( "directive-class", { | ||
state: { | ||
trueValue: true, | ||
falseValue: false, | ||
const { state } = store( 'directive-class', { | ||
state: { | ||
trueValue: true, | ||
falseValue: false, | ||
}, | ||
actions: { | ||
toggleTrueValue: () => { | ||
state.trueValue = ! state.trueValue; | ||
}, | ||
actions: { | ||
toggleTrueValue: () => { | ||
state.trueValue = ! state.trueValue; | ||
}, | ||
toggleFalseValue: () => { | ||
state.falseValue = ! state.falseValue; | ||
}, | ||
toggleContextFalseValue: () => { | ||
const context = getContext(); | ||
context.falseValue = ! context.falseValue; | ||
}, | ||
toggleFalseValue: () => { | ||
state.falseValue = ! state.falseValue; | ||
}, | ||
} ); | ||
} )( window ); | ||
toggleContextFalseValue: () => { | ||
const context = getContext(); | ||
context.falseValue = ! context.falseValue; | ||
}, | ||
}, | ||
} ); |
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
Oops, something went wrong.