-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial rendering test as example for other components
- Loading branch information
Kim Scott
committed
Nov 17, 2020
1 parent
1486aeb
commit 0cdc2ee
Showing
3 changed files
with
103 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import Ember from 'ember'; | ||
import DS from 'ember-data'; | ||
import {moduleForComponent} from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
import sinon from 'sinon'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
|
||
|
||
module('Integration | Component | exp lookit survey', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('Exp-lookit-survey frame renders', async function (assert) { | ||
|
||
assert.expect(2); | ||
let formSchema = { | ||
schema: { | ||
type: "object", | ||
title: "Tell us about your pet!", | ||
properties: { | ||
"age": { | ||
"type": "integer", | ||
"title": "Age", | ||
"maximum": 200, | ||
"minimum": 0, | ||
"required": true | ||
}, | ||
"name": { | ||
"type": "string", | ||
"title": "Name", | ||
"required": true | ||
}, | ||
"species": { | ||
"enum": [ | ||
"dog", | ||
"cat", | ||
"fish", | ||
"bird", | ||
"raccoon" | ||
], | ||
"type": "string", | ||
"title": "What type of animal?", | ||
"default": "" | ||
} | ||
} | ||
}, | ||
options: { | ||
fields: { | ||
age: { | ||
"numericEntry": true | ||
}, | ||
name: { | ||
"placeholder": "a name..." | ||
}, | ||
species: { | ||
"type": "radio", | ||
"message": "Seriously, what species??", | ||
"validator": "required-field" | ||
} | ||
} | ||
} | ||
}; | ||
|
||
this.set('formSchema', formSchema); | ||
await this.render( | ||
hbs`{{exp-lookit-survey | ||
nextButtonText="Moving on" | ||
formSchema=formSchema | ||
}}` | ||
); | ||
|
||
// Note: not all questions appear to be rendered at this time. May need to wait for that separately... | ||
assert.equal(this.element.querySelector('legend').textContent.trim(), 'Tell us about your pet!'); | ||
assert.equal(this.element.querySelector('button').textContent.trim(), 'Moving on'); | ||
}); | ||
}); |
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,23 @@ | ||
import { colorSpecToRgbaArray, isColor } from '../../../utils/is-color'; | ||
import { module, test} from 'qunit'; | ||
|
||
|
||
module('Unit | Utility | is color'); | ||
|
||
test('Valid CSS color syntax recognized', function(assert) { | ||
assert.ok(isColor('black'), 'Black is a color'); | ||
assert.notOk(isColor('blark'), 'Blark is not a color'); | ||
|
||
assert.ok(isColor('#cc00ff'), '#cc00ff is a color'); | ||
assert.notOk(isColor('cc00ff'), 'cc00ff is not a color'); | ||
}); | ||
|
||
test('CSS color specs correctly turned into RGBA arrays', function(assert) { | ||
let black = new Uint8ClampedArray([0, 0, 0, 255]); | ||
assert.deepEqual(colorSpecToRgbaArray('black'), black); | ||
assert.deepEqual(colorSpecToRgbaArray('#000'), black); | ||
|
||
let limegreen = new Uint8ClampedArray([0, 255, 0, 255]); | ||
assert.deepEqual(colorSpecToRgbaArray('lime'), limegreen); | ||
assert.deepEqual(colorSpecToRgbaArray('#0f0'), limegreen); | ||
}); |