-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added everything for Step 4: Testing a New Module
- Loading branch information
Showing
3 changed files
with
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sap.ui.define([ | ||
"sap/ui/model/SimpleType" | ||
], function (SimpleType) { | ||
"use strict"; | ||
return SimpleType.extend("com.mrb.UI5-Testing.model.FlaggedType", { | ||
formatValue: function () { | ||
}, | ||
parseValue: function () { | ||
}, | ||
validateValue: function () { | ||
} | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sap.ui.define(["./model/models", "./model/formatter"], function () { | ||
sap.ui.define(["./model/models", "./model/formatter", "./model/FlaggedType"], function () { | ||
"use strict"; | ||
}); |
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,56 @@ | ||
/*global QUnit*/ | ||
sap.ui.require(["com/mrb/UI5-Testing/model/FlaggedType"], function ( | ||
FlaggedType | ||
) { | ||
"use strict"; | ||
QUnit.module("FlaggedType - formatting"); | ||
|
||
QUnit.test("Should convert 1 to true", function (assert) { | ||
//Act | ||
var bFormattedValue = new FlaggedType().formatValue(1); | ||
//Assert | ||
assert.strictEqual( | ||
bFormattedValue, | ||
true, | ||
"The formatting conversion was correct" | ||
); | ||
}); | ||
QUnit.test("Should convert other values to false", function (assert) { | ||
var oFlaggedType = new FlaggedType(); | ||
// Act | ||
var bFormattedZero = oFlaggedType.formatValue(0); | ||
var bFormattedNegativeNumber = oFlaggedType.formatValue(-666); | ||
// Assert | ||
assert.strictEqual( | ||
bFormattedZero, | ||
false, | ||
"The formatting conversion was correct" | ||
); | ||
assert.strictEqual( | ||
bFormattedNegativeNumber, | ||
false, | ||
"The formatting conversion was correct" | ||
); | ||
}); | ||
QUnit.module("FlaggedType - parsing"); | ||
QUnit.test("Should parse false to 0", function (assert) { | ||
// Act | ||
var iParsedValue = new FlaggedType().parseValue(false); | ||
// Assert | ||
assert.strictEqual( | ||
iParsedValue, | ||
0, | ||
"The parsing conversion matched the input" | ||
); | ||
}); | ||
QUnit.test("Should parse true to 1", function (assert) { | ||
// Act | ||
var iParsedValue = new FlaggedType().parseValue(true); | ||
// Assert | ||
assert.strictEqual( | ||
iParsedValue, | ||
1, | ||
"The parsing conversion matched the input" | ||
); | ||
}); | ||
}); |