-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* style binding * +
- Loading branch information
Showing
12 changed files
with
228 additions
and
30 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
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 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,66 @@ | ||
import { module, test } from 'qunit'; | ||
import { render, rerender } from '@lifeart/gxt/test-utils'; | ||
import { cell } from '@lifeart/gxt'; | ||
|
||
module('Integration | component | functional', function () { | ||
test('should render text', async function (assert) { | ||
function HelloWolrd() { | ||
return <template>123</template>; | ||
} | ||
await render(<template><HelloWolrd /></template>); | ||
assert.dom().hasText('123'); | ||
}); | ||
test('should render node', async function (assert) { | ||
function HelloWolrd() { | ||
return <template> | ||
<div>123</div> | ||
</template>; | ||
} | ||
await render(<template><HelloWolrd /></template>); | ||
assert.dom('div').hasText('123'); | ||
}); | ||
test('support static args', async function (assert) { | ||
function HelloWolrd() { | ||
return <template> | ||
<div>{{@name}}</div> | ||
</template>; | ||
} | ||
await render(<template><HelloWolrd @name={{'123'}} /></template>); | ||
assert.dom('div').hasText('123'); | ||
}); | ||
test('support static args from functional params', async function (assert) { | ||
const HelloWolrd = ({ name }) => { | ||
return <template> | ||
<div>{{name}}</div> | ||
</template>; | ||
}; | ||
await render(<template><HelloWolrd @name={{'123'}} /></template>); | ||
assert.dom('div').hasText('123'); | ||
}); | ||
test('support dynamic args from functional params', async function (assert) { | ||
const value = cell('123'); | ||
const HelloWolrd = ({ name }) => { | ||
return <template> | ||
<div>{{name}}</div> | ||
</template>; | ||
}; | ||
await render(<template><HelloWolrd @name={{value}} /></template>); | ||
assert.dom('div').hasText('123'); | ||
value.update('321'); | ||
await rerender(); | ||
assert.dom('div').hasText('321'); | ||
}); | ||
test('support dynamic args from functional params reference', async function (assert) { | ||
const value = cell('123'); | ||
const HelloWolrd = (args) => { | ||
return <template> | ||
<div>{{args.name}}</div> | ||
</template>; | ||
}; | ||
await render(<template><HelloWolrd @name={{value.value}} /></template>); | ||
assert.dom('div').hasText('123'); | ||
value.update('321'); | ||
await rerender(); | ||
assert.dom('div').hasText('321'); | ||
}); | ||
}); |
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,69 @@ | ||
import { module, test } from 'qunit'; | ||
import { render, rerender, click } from '@lifeart/gxt/test-utils'; | ||
import { cell, Component, tracked } from '@lifeart/gxt'; | ||
|
||
module('Integration | Interal | style', function () { | ||
test('works with static style binding', async function (assert) { | ||
await render( | ||
<template> | ||
<div style.color={{'green'}}>123</div> | ||
</template>, | ||
); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(0, 128, 0)', | ||
}); | ||
}); | ||
test('works with dynamic binding', async function (assert) { | ||
const color = cell('red'); | ||
await render( | ||
<template> | ||
<div style.color={{color}}>123</div> | ||
</template>, | ||
); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(255, 0, 0)', | ||
}); | ||
color.update('blue'); | ||
await rerender(); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(0, 0, 255)', | ||
}); | ||
}); | ||
test('works with dynamic binding in class', async function (assert) { | ||
class MyComponent { | ||
@tracked color = 'red'; | ||
onClick = () => { | ||
this.color = 'blue'; | ||
}; | ||
<template> | ||
<div style.color={{this.color}}>123</div> | ||
<button type='button' {{on 'click' this.onClick}}>change color</button> | ||
</template> | ||
} | ||
await render(<template><MyComponent /></template>); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(255, 0, 0)', | ||
}); | ||
await click('button'); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(0, 0, 255)', | ||
}); | ||
}); | ||
test('works with functions', async function (assert) { | ||
const color = cell('red'); | ||
const getColor = () => color.value; | ||
await render( | ||
<template> | ||
<div style.color={{getColor}}>123</div> | ||
</template>, | ||
); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(255, 0, 0)', | ||
}); | ||
color.update('blue'); | ||
await rerender(); | ||
assert.dom('div').hasStyle({ | ||
color: 'rgb(0, 0, 255)', | ||
}); | ||
}); | ||
}); |
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