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

Landscaper: QUnit2 upgrade #59

Merged
merged 1 commit into from
May 27, 2019
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
38 changes: 19 additions & 19 deletions can-validate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ var isEmptyObject = function(value) {

QUnit.module("Map Validate Plugin");

QUnit.test("when validateOnInit is not set, it should not run validation",function(){
QUnit.test("when validateOnInit is not set, it should not run validation",function(assert) {
validatedMap = new ValidatedMap();
QUnit.ok(isEmptyObject(validatedMap.errors));
assert.ok(isEmptyObject(validatedMap.errors));
});

QUnit.test("validations run when value is set",function(){
QUnit.test("validations run when value is set",function(assert) {
validatedMap = new ValidatedMap();
validatedMap.attr("myNumber", "");
QUnit.equal(validatedMap.errors.myNumber.length, 1);
assert.equal(validatedMap.errors.myNumber.length, 1);
});

// #27 - Validate method does not resolve computes
QUnit.test("when validate method is called, resolves computes before calling Validate method",function(){
QUnit.test("when validate method is called, resolves computes before calling Validate method",function(assert) {
validatedMap = new ValidatedMap({
isRequired: true,
myNumber: 0
Expand All @@ -64,7 +64,7 @@ QUnit.test("when validate method is called, resolves computes before calling Val
} catch (err) {
success = err;
}
QUnit.ok(success);
assert.ok(success);
});

/**
Expand All @@ -73,7 +73,7 @@ QUnit.test("when validate method is called, resolves computes before calling Val
* props, it overwrote the prototype of the map instead of creating a unique
* version for each map instance.
*/
QUnit.test("when creating multiple instances of the same map, each instance is discrete",function(){
QUnit.test("when creating multiple instances of the same map, each instance is discrete",function(assert) {
// Doing this should not affect our control. If bug exists, it will
// affect all instances
validatedMap = new ValidatedMap();
Expand All @@ -83,12 +83,12 @@ QUnit.test("when creating multiple instances of the same map, each instance is d
secondaryMap = new ValidatedMap();

secondaryMap.attr("computedProp", "");
QUnit.equal(isEmptyObject(secondaryMap.attr("errors")), true, 'control map validates successfully');
assert.equal(isEmptyObject(secondaryMap.attr("errors")), true, 'control map validates successfully');

// other map validates, sets error
validatedMap.attr("computedProp", "");
QUnit.equal(validatedMap.attr("computedProp"), "");
QUnit.ok(typeof validatedMap.attr("errors.computedProp") !== "undefined", 'other map validates, sets error');
assert.equal(validatedMap.attr("computedProp"), "");
assert.ok(typeof validatedMap.attr("errors.computedProp") !== "undefined", 'other map validates, sets error');
});

var ShimValidatedMap = Map.extend({
Expand All @@ -112,24 +112,24 @@ var ShimValidatedMap = Map.extend({
});

QUnit.module("Validate.js Shim", {
setup: function(){
beforeEach: function(assert) {
validatedMap = new ShimValidatedMap({});
}
});

QUnit.test("validates on init by default",function(){
QUnit.equal(validatedMap.attr('errors').myNumber.length, 1);
QUnit.test("validates on init by default",function(assert) {
assert.equal(validatedMap.attr('errors').myNumber.length, 1);
});

QUnit.test("validates on init by default",function(){
QUnit.equal(validatedMap.errors.myNumber.length, 1);
QUnit.test("validates on init by default",function(assert) {
assert.equal(validatedMap.errors.myNumber.length, 1);
});

QUnit.test("does not validate on init, when validate on init is false",function(){
QUnit.equal(validatedMap.errors.myString, undefined);
QUnit.test("does not validate on init, when validate on init is false",function(assert) {
assert.equal(validatedMap.errors.myString, undefined);
});

QUnit.test("runs validation on value",function(){
QUnit.test("runs validation on value",function(assert) {
validatedMap.attr("myString", "");
QUnit.equal(validatedMap.errors.myString.length, 1);
assert.equal(validatedMap.errors.myString.length, 1);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"jquery": "^3.1.1",
"jshint": "^2.9.1",
"steal": "^1.2.10",
"steal-qunit": "^1.0.1",
"steal-qunit": "^2.0.0",
"steal-stache": "^3.0.1",
"steal-tools": "^1.1.2",
"testee": "^0.9.0"
Expand Down