/
directives-text.spec.ts
45 lines (41 loc) · 1.64 KB
/
directives-text.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Internal dependencies
*/
import { test, expect } from './fixtures';
test.describe( 'data-wp-text', () => {
test.beforeAll( async ( { interactivityUtils: utils } ) => {
await utils.activatePlugins();
await utils.addPostWithBlock( 'test/directive-text' );
} );
test.beforeEach( async ( { interactivityUtils: utils, page } ) => {
await page.goto( utils.getLink( 'test/directive-text' ) );
} );
test.afterAll( async ( { interactivityUtils: utils } ) => {
await utils.deactivatePlugins();
await utils.deleteAllPosts();
} );
test( 'show proper text reading from state', async ( { page } ) => {
const el = page.getByTestId( 'show state text' );
await expect( el ).toHaveText( 'Text 1' );
await page.getByTestId( 'toggle state text' ).click();
await expect( el ).toHaveText( 'Text 2' );
await page.getByTestId( 'toggle state text' ).click();
await expect( el ).toHaveText( 'Text 1' );
} );
test( 'show proper text reading from context', async ( { page } ) => {
const el = page.getByTestId( 'show context text' );
await expect( el ).toHaveText( 'Text 1' );
await page.getByTestId( 'toggle context text' ).click();
await expect( el ).toHaveText( 'Text 2' );
await page.getByTestId( 'toggle context text' ).click();
await expect( el ).toHaveText( 'Text 1' );
} );
test( 'work only with strings', async ( { page } ) => {
const elObject = page.getByTestId( 'show state component' );
await expect( elObject ).toBeHidden();
const elNumber = page.getByTestId( 'show state number' );
await expect( elNumber ).toBeHidden();
const elBool = page.getByTestId( 'show state boolean' );
await expect( elBool ).toBeHidden();
} );
} );