Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed liter errors, updated QUnit #112

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions commons/selfservice/example-ui/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ module.exports = function(grunt) {
watch: {
sync_and_test: {
files: [
'<%= forgerockui %>/forgerock-ui-commons/src/main/js/**',
'<%= forgerockui %>/forgerock-ui-commons/src/main/resources/**',
//'<%= forgerockui %>/forgerock-ui-commons/src/test/qunit/**',
'<%= forgerockui %>/forgerock-ui-user/src/main/js/**',
'<%= forgerockui %>/forgerock-ui-user/src/main/resources/**',
//'<%= forgerockui %>/forgerock-ui-user/src/test/qunit/**',
'<%= forgerockui %>/commons/src/main/js/**',
'<%= forgerockui %>/commons/src/main/resources/**',
//'<%= forgerockui %>/commons/src/test/qunit/**',
'<%= forgerockui %>/user/src/main/js/**',
'<%= forgerockui %>/user/src/main/resources/**',
//'<%= forgerockui %>/user/src/test/qunit/**',
'src/main/js/**',
'src/main/resources/**',
//'src/test/qunit/**',
Expand All @@ -56,17 +56,17 @@ module.exports = function(grunt) {
commons: {
files: [
{
cwd : '<%= forgerockui %>/forgerock-ui-commons/src/main/js',
cwd : '<%= forgerockui %>/commons/src/main/js',
src : ['**'],
dest : 'target/www'
},
{
cwd : '<%= forgerockui %>/forgerock-ui-commons/src/main/resources',
cwd : '<%= forgerockui %>/commons/src/main/resources',
src : ['**'],
dest : 'target/www'
}/*,
{
cwd : '<%= forgerockui %>/forgerock-ui-commons/src/test/qunit',
cwd : '<%= forgerockui %>/commons/src/test/qunit',
src : ['**'],
dest : 'target/test/tests'
}*/
Expand All @@ -75,17 +75,17 @@ module.exports = function(grunt) {
user: {
files: [
{
cwd : '<%= forgerockui %>/forgerock-ui-user/src/main/js',
cwd : '<%= forgerockui %>/user/src/main/js',
src : ['**'],
dest : 'target/www'
},
{
cwd : '<%= forgerockui %>/forgerock-ui-user/src/main/resources',
cwd : '<%= forgerockui %>/user/src/main/resources',
src : ['**'],
dest : 'target/www'
}/*,
{
cwd : '<%= forgerockui %>/forgerock-ui-user/src/test/qunit',
cwd : '<%= forgerockui %>/user/src/test/qunit',
src : ['**'],
dest : 'target/test/tests'
}*/
Expand Down
1 change: 0 additions & 1 deletion ui/commons/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"root": true,
"extends": "forgerock",
"env": {
"amd": true,
"browser": true,
Expand Down
1 change: 0 additions & 1 deletion ui/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"devDependencies": {
"eslint": "4.18.2",
"eslint-config-forgerock": "^1.0.0",
"eslint-formatter-warning-summary": "^1.0.1",
"grunt": "1.5.3",
"grunt-cli": "1.4.3",
Expand Down
2 changes: 1 addition & 1 deletion ui/commons/src/main/js/config/process/CommonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ define([
{
startEvent: Constants.EVENT_UNAUTHORIZED,
description: "",
dependencies: [ ],
dependencies: [],
processDescription: function() {
EventManager.sendEvent(Constants.EVENT_DISPLAY_MESSAGE_REQUEST, "unauthorized");
}
Expand Down
10 changes: 5 additions & 5 deletions ui/commons/src/main/js/config/validators/CommonValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([
var obj = {
"required": {
"name": "Required field",
"dependencies": [ ],
"dependencies": [],
"validator": function(el, input, callback) {
var v = input.val();
if (!v || v === "") {
Expand All @@ -33,7 +33,7 @@ define([
},
"passwordConfirm": {
"name": "Password confirmation",
"dependencies": [ ],
"dependencies": [],
"validator": function(el, input, callback) {
var confirmValue = input.val(),
mainInput = el.find(":input#" + input.attr("passwordField"));
Expand All @@ -47,7 +47,7 @@ define([
},
"minLength": {
"name": "Minimum number of characters",
"dependencies": [ ],
"dependencies": [],
"validator": function(el, input, callback) {
var v = input.val(),
len = input.attr('minLength');
Expand All @@ -61,7 +61,7 @@ define([
},
"atLeastXNumbers": {
"name": "Minimum occurrence of numeric characters in string",
"dependencies": [ ],
"dependencies": [],
"validator": function(el, input, callback) {
var v = input.val(),
minNumbers = input.attr('atLeastXNumbers'),
Expand All @@ -76,7 +76,7 @@ define([
},
"atLeastXCapitalLetters": {
"name": "Minimum occurrence of capital letter characters in string",
"dependencies": [ ],
"dependencies": [],
"validator": function(el, input, callback) {
var v = input.val(),
minCapitals = input.attr('atLeastXCapitalLetters'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ define([
if(service) {
service[methodName].apply(service, params || []);
}
}, function (exception) {
},
function (exception) {
if(params) {
params = JSON.stringify(params);
}
Expand Down
22 changes: 11 additions & 11 deletions ui/commons/src/test/qunit/AbstractCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define([
], function ($, sinon, AbstractCollection, ServiceInvoker) {
QUnit.module('AbstractCollection Functions');

QUnit.test("query operations", function () {
QUnit.test("query operations", function (assert) {
var testCollection = new AbstractCollection(),
restCallArg;

Expand Down Expand Up @@ -58,31 +58,31 @@ define([
testCollection.setTotalPagedResultsPolicy("EXACT");

testCollection.getFirstPage().then(function () {
QUnit.equal(ServiceInvoker.restCall.callCount, 1, "Only one REST call produced");
assert.equal(ServiceInvoker.restCall.callCount, 1, "Only one REST call produced");
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(testCollection.length, 2, "collection contains two records from the backend");
QUnit.equal(testCollection.where({givenName: "Boaty"}).length, 1,
assert.equal(testCollection.length, 2, "collection contains two records from the backend");
assert.equal(testCollection.where({givenName: "Boaty"}).length, 1,
"able to find expected model content in collection");
QUnit.ok(testCollection.hasNext(), "response with cookie indicates that hasNext is true");
QUnit.equal(testCollection.state.totalRecords, 5, "Total records correctly populated in collection state");
QUnit.equal(testCollection.state.totalPages, 3, "Total pages correctly populated in collection state");
QUnit.equal(restCallArg.url, "/crestResource", "correct url used to query backend");
QUnit.equal(restCallArg.data,
assert.ok(testCollection.hasNext(), "response with cookie indicates that hasNext is true");
assert.equal(testCollection.state.totalRecords, 5, "Total records correctly populated in collection state");
assert.equal(testCollection.state.totalPages, 3, "Total pages correctly populated in collection state");
assert.equal(restCallArg.url, "/crestResource", "correct url used to query backend");
assert.equal(restCallArg.data,
"_queryFilter=true&_pageSize=2&_sortKeys=givenName&_totalPagedResultsPolicy=EXACT",
"correct data submitted to backend for first page");
}).then(function () {
testCollection.setSorting("givenName", 1);
return testCollection.getFirstPage();
}).then(function () {
restCallArg = ServiceInvoker.restCall.args[1][0]; // second invocation, first argument
QUnit.equal(restCallArg.data,
assert.equal(restCallArg.data,
"_queryFilter=true&_pageSize=2&_sortKeys=-givenName&_totalPagedResultsPolicy=EXACT",
"correct data submitted to backend for descending sortKey");
}).then(function () {
return testCollection.getNextPage();
}).then(function () {
restCallArg = ServiceInvoker.restCall.args[2][0]; // third invocation, first argument
QUnit.equal(restCallArg.data,
assert.equal(restCallArg.data,
"_queryFilter=true&_pageSize=2&_sortKeys=-givenName"+
"&_totalPagedResultsPolicy=EXACT&_pagedResultsCookie=2",
"correct data submitted to backend for next page");
Expand Down
64 changes: 32 additions & 32 deletions ui/commons/src/test/qunit/AbstractModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define([
], function ($, sinon, AbstractModel, ServiceInvoker) {
QUnit.module('AbstractModel Functions');

QUnit.test("create with server-assigned id", function () {
QUnit.test("create with server-assigned id", function (assert) {
var testModel = new AbstractModel(),
newRecord = {
"foo": "bar",
Expand All @@ -41,15 +41,15 @@ define([

testModel.save(newRecord).then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(testModel.id, 1, "Newly-created model has id from backend");
QUnit.equal(restCallArg.url, "/crestResource?_action=create&", "correct url used to create model");
QUnit.equal(restCallArg.type, "POST", "correct method used to create model");
assert.equal(testModel.id, 1, "Newly-created model has id from backend");
assert.equal(restCallArg.url, "/crestResource?_action=create&", "correct url used to create model");
assert.equal(restCallArg.type, "POST", "correct method used to create model");
ServiceInvoker.restCall.restore();
});

});

QUnit.test("create with client-supplied id", function () {
QUnit.test("create with client-supplied id", function (assert) {
var testModel = new AbstractModel(),
newRecord = {
"foo": "bar",
Expand All @@ -68,16 +68,16 @@ define([

testModel.save(newRecord).then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(testModel.get("_rev"), 1, "Model has new rev from backend");
QUnit.equal(restCallArg.url, "/crestResource/myCustomId?", "correct url used to create model");
QUnit.equal(restCallArg.headers["If-None-Match"], "*", "correct revision header provided");
QUnit.equal(restCallArg.type, "PUT", "correct method used to create model");
assert.equal(testModel.get("_rev"), 1, "Model has new rev from backend");
assert.equal(restCallArg.url, "/crestResource/myCustomId?", "correct url used to create model");
assert.equal(restCallArg.headers["If-None-Match"], "*", "correct revision header provided");
assert.equal(restCallArg.type, "PUT", "correct method used to create model");

ServiceInvoker.restCall.restore();
})
});

QUnit.test("read operation", function () {
QUnit.test("read operation", function (assert) {
var testModel = new AbstractModel(),
restCallArg;

Expand All @@ -94,30 +94,30 @@ define([

testModel.fetch().then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(testModel.get("name"), "foo", "example data populated from fetch call");
QUnit.equal(testModel.get("_rev"), 1, "revision populated from fetch call");
QUnit.equal(restCallArg.url, "/crestResource/1?", "correct url used to read model");
QUnit.equal(restCallArg.type, "GET", "correct method used to read model");
assert.equal(testModel.get("name"), "foo", "example data populated from fetch call");
assert.equal(testModel.get("_rev"), 1, "revision populated from fetch call");
assert.equal(restCallArg.url, "/crestResource/1?", "correct url used to read model");
assert.equal(restCallArg.type, "GET", "correct method used to read model");
}).then(function () {
testModel.additionalParameters = {
"_fields": "name"
};
return testModel.fetch();
}).then(function () {
restCallArg = ServiceInvoker.restCall.args[1][0]; // second invocation, first argument
QUnit.equal(restCallArg.url, "/crestResource/1?_fields=name", "url includes additionalParameters");
assert.equal(restCallArg.url, "/crestResource/1?_fields=name", "url includes additionalParameters");
}).then(function () {
testModel.parse = function (response) {
return _.extend({"addedByParseFunction": true}, response);
};
return testModel.fetch();
}).then(function () {
QUnit.equal(testModel.get("addedByParseFunction"), true, "parse function successfully modified model content");
assert.equal(testModel.get("addedByParseFunction"), true, "parse function successfully modified model content");
ServiceInvoker.restCall.restore();
});
});

QUnit.test("update operations", function () {
QUnit.test("update operations", function (assert) {
var testModel = new AbstractModel({
"_id": 1,
"_rev": 1,
Expand All @@ -136,16 +136,16 @@ define([

testModel.save().then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(testModel.get("_rev"), 2, "Model has new rev from backend");
QUnit.equal(restCallArg.url, "/crestResource/1?", "correct url used to update model");
QUnit.equal(restCallArg.headers["If-Match"], 1, "correct revision header provided");
QUnit.equal(restCallArg.type, "PUT", "correct method used to update model");
assert.equal(testModel.get("_rev"), 2, "Model has new rev from backend");
assert.equal(restCallArg.url, "/crestResource/1?", "correct url used to update model");
assert.equal(restCallArg.headers["If-Match"], 1, "correct revision header provided");
assert.equal(restCallArg.type, "PUT", "correct method used to update model");

ServiceInvoker.restCall.restore();
});
});

QUnit.test("delete operations", function () {
QUnit.test("delete operations", function (assert) {
var testModel = new AbstractModel({
"_id": 1,
"_rev": 1,
Expand All @@ -162,14 +162,14 @@ define([

testModel.destroy().then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument
QUnit.equal(restCallArg.url, "/crestResource/1?", "correct url used to delete model");
QUnit.equal(restCallArg.type, "DELETE", "correct method used to DELETE model");
assert.equal(restCallArg.url, "/crestResource/1?", "correct url used to delete model");
assert.equal(restCallArg.type, "DELETE", "correct method used to DELETE model");

ServiceInvoker.restCall.restore();
});
});

QUnit.test("patch operations", function () {
QUnit.test("patch operations", function (assert) {
var testModel = new AbstractModel({
"_id": 1,
"_rev": 1,
Expand All @@ -187,15 +187,15 @@ define([
testModel.save({"foo": "baz"}, {patch: true}).then(function () {
restCallArg = ServiceInvoker.restCall.args[0][0]; // first invocation, first argument

QUnit.equal(restCallArg.url, "/crestResource/1?", "correct url used to patch model");
QUnit.equal(restCallArg.type, "PATCH", "correct method used to patch model");
QUnit.equal(restCallArg.data, '[{"operation":"replace","field":"/foo","value":"baz"}]', "correct patch content provided");
assert.equal(restCallArg.url, "/crestResource/1?", "correct url used to patch model");
assert.equal(restCallArg.type, "PATCH", "correct method used to patch model");
assert.equal(restCallArg.data, '[{"operation":"replace","field":"/foo","value":"baz"}]', "correct patch content provided");

ServiceInvoker.restCall.restore();
});
});

QUnit.test("custom get method to support JSONPointer", function () {
QUnit.test("custom get method to support JSONPointer", function (assert) {
var testModel = new AbstractModel({
"_id": 1,
"_rev": 1,
Expand All @@ -204,9 +204,9 @@ define([
"hello": "world"
}
});
QUnit.equal(testModel.get("simpleKey"), "simpleValue", "basic get behavior used to get simple value");
QUnit.equal(testModel.get("/simpleKey"), "simpleValue", "jsonpointer used to get simple value");
QUnit.equal(testModel.get("/foo/hello"), "world", "jsonpointer used to get deeply-nested value");
assert.equal(testModel.get("simpleKey"), "simpleValue", "basic get behavior used to get simple value");
assert.equal(testModel.get("/simpleKey"), "simpleValue", "jsonpointer used to get simple value");
assert.equal(testModel.get("/foo/hello"), "world", "jsonpointer used to get deeply-nested value");
})

});
Loading