-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GPII-3553: Added tests for "check required options" grade.
- Loading branch information
1 parent
451bed2
commit 9f4f117
Showing
4 changed files
with
114 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// TODO: This should be removed as soon as "schema-validated components" are available. | ||
// Test "has required options" grade using `gpii-test-browser`. | ||
// | ||
/* eslint-env node */ | ||
"use strict"; | ||
var fluid = require("infusion"); | ||
var gpii = fluid.registerNamespace("gpii"); | ||
|
||
require("./includes.js"); | ||
|
||
fluid.registerNamespace("gpii.tests.handlebars.browser.hasRequiredOptions"); | ||
|
||
gpii.tests.handlebars.browser.hasRequiredOptions.createComponent = function (options) { | ||
try { | ||
gpii.tests.handlebars.hasRequiredOptions(options); | ||
return true; | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
}; | ||
|
||
fluid.defaults("gpii.tests.handlebars.browser.hasRequiredOptions.caseHolder", { | ||
gradeNames: ["gpii.test.handlebars.browser.caseHolder"], | ||
rawModules: [{ | ||
name: "Testing the `hasRequiredOptions` client-side grade...", | ||
tests: [ | ||
{ | ||
name: "Confirm that required options are checked correctly...", | ||
sequence: [ | ||
{ | ||
func: "{testEnvironment}.webdriver.get", | ||
args: ["{testEnvironment}.options.url"] | ||
}, | ||
{ | ||
event: "{testEnvironment}.webdriver.events.onGetComplete", | ||
listener: "{testEnvironment}.webdriver.executeScript", | ||
args: [gpii.tests.handlebars.browser.hasRequiredOptions.createComponent, {}] | ||
}, | ||
{ | ||
event: "{testEnvironment}.webdriver.events.onExecuteScriptComplete", | ||
listener: "jqUnit.assertEquals", | ||
args: ["Omitting all options should result in failure.", false, "{arguments}.0"] | ||
}, | ||
{ | ||
func: "{testEnvironment}.webdriver.executeScript", | ||
args: [gpii.tests.handlebars.browser.hasRequiredOptions.createComponent, { skittles: true }] | ||
}, | ||
{ | ||
event: "{testEnvironment}.webdriver.events.onExecuteScriptComplete", | ||
listener: "jqUnit.assertEquals", | ||
args: ["Omitting one option should result in failure.", false, "{arguments}.0"] | ||
}, | ||
{ | ||
func: "{testEnvironment}.webdriver.executeScript", | ||
args: [gpii.tests.handlebars.browser.hasRequiredOptions.createComponent, { beer: true, skittles: true }] | ||
}, | ||
{ | ||
event: "{testEnvironment}.webdriver.events.onExecuteScriptComplete", | ||
listener: "jqUnit.assertEquals", | ||
args: ["Supplying all options should result in success.", true, "{arguments}.0"] | ||
} | ||
] | ||
} | ||
] | ||
}] | ||
}); | ||
|
||
fluid.defaults("gpii.tests.handlebars.browser.hasRequiredOptions.testEnvironment", { | ||
gradeNames: ["gpii.test.handlebars.browser.environment"], | ||
"port": 6924, | ||
"path": "content/tests-hasRequiredOptions.html", | ||
components: { | ||
caseHolder: { | ||
type: "gpii.tests.handlebars.browser.hasRequiredOptions.caseHolder" | ||
} | ||
} | ||
}); | ||
|
||
gpii.test.webdriver.allBrowsers({ baseTestEnvironment: "gpii.tests.handlebars.browser.hasRequiredOptions.testEnvironment"}); |
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,15 @@ | ||
"use strict"; | ||
// Test the "has required options" grade. | ||
// | ||
// This is a test component that is meant to be included in a client-side document. | ||
// | ||
/* global fluid */ | ||
/* eslint-env node */ | ||
fluid.defaults("gpii.tests.handlebars.hasRequiredOptions", { | ||
gradeNames: ["gpii.hasRequiredOptions"], | ||
template: "common-success", | ||
requiredFields: { | ||
beer: true, | ||
skittles: true | ||
} | ||
}); |
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,18 @@ | ||
<html> | ||
<head> | ||
<title>Tests for "Required Options" grade.</title> | ||
|
||
<!-- Bring in jQuery and fluid dependencies --> | ||
<script type="text/javascript" src="../../node_modules/infusion/dist/infusion-all.js"></script> | ||
<script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/MessageResolver.js"></script> | ||
|
||
<!-- The code we are testing --> | ||
<script type="text/javascript" src="../../src/js/client/hasRequiredOptions.js"></script> | ||
|
||
<!-- Bring in our test helper --> | ||
<script type="text/javascript" src="./js/tests-hasRequiredOptions.js"></script> | ||
</head> | ||
<body> | ||
<p>This page is used to test the "check required options" component in isolation. There are no visible test fixtures.</p> | ||
</body> | ||
</html> |