So basically I want to test this function I made. You type in a number "normal_cost" and then in returns 0.2x this value.
const saver = Object.create(null);
const change = (id) => document.getElementById(id);
saver.init = function () {
change("x").onclick = function multiply() {
var a, result;
a = document.getElementById("normal_cost").value;
result = Math.round((a * 0.2) * 100) / 100;
document.getElementById("r").innerHTML = result
};
};
export default Object.freeze(saver);
This is the fast-check test I made but I am not sure what to write after 'return' in the test file below.. Any help would be brilliant thanks!
import multiply from "./saver.js";
import result from "./saver.js";
import a from "./saver.js";
const describe = window.describe;
const it = window.it;
const fc = window.fastcheck;
const chai = window.chai;
const arbNumber = fc.nat(1000);
describe("Property Based Testing", function () {
it(
"Given a number;" +
"after performing a move;" +
"Score is 0.2 times the number before", function () {
fc.assert(fc.property(
arbNumber,
function(normal_cost) {
return multiply.result(normal_cost) === 0.2 * multiply.a(normal_cost);
}
),{"verbose":true})}
)
});
Aucun commentaire:
Enregistrer un commentaire