-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from toddjordan/data-binding
Adding a way to provide a data object to the component apart from the schema
- Loading branch information
Showing
4 changed files
with
73 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//import Ember from 'ember'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
|
||
const schemaObject = { | ||
"schema": { | ||
"title": "What do you think of Alpaca?", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"title": "Name" | ||
}, | ||
"ranking": { | ||
"type": "string", | ||
"title": "Ranking", | ||
"enum": ['excellent', 'not too shabby', 'alpaca built my hotrod'] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const dataObject = { | ||
"name": "Todd Jordan", | ||
"ranking": "not too shabby" | ||
}; | ||
|
||
moduleForComponent('/dynamic-form' , 'Integration | Component | dynamic-form:data-binding', { | ||
integration: true | ||
}); | ||
|
||
test('should update input value when model updated', function (assert) { | ||
const fixtureSchema = _.clone(schemaObject, true); | ||
const done = assert.async(); | ||
fixtureSchema.postRender = () => { | ||
assert.equal(this.$('.alpaca-field-text input').val(), 'Todd Jordan'); | ||
dataObject.name = 'Jeremy Rowe'; | ||
fixtureSchema.postRender = () => { | ||
assert.equal(this.$('.alpaca-field-text input').val(), 'Jeremy Rowe'); | ||
done(); | ||
}; | ||
this.render(hbs`{{dynamic-form schema=schemaObject data=dataObject}}`); | ||
}; | ||
this.set('schemaObject', fixtureSchema); | ||
this.set('dataObject', dataObject); | ||
this.render(hbs`{{dynamic-form schema=schemaObject data=dataObject}}`); | ||
}); |
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