diff --git a/test.html b/test.html new file mode 100644 index 0000000..6d59ba2 --- /dev/null +++ b/test.html @@ -0,0 +1,9 @@ + + +

Look at the developer console for the test results.

+

If you are just using ziba, then you probably won't care about this file.

+ + diff --git a/ziba_test.js b/ziba_test.js new file mode 100644 index 0000000..361c00b --- /dev/null +++ b/ziba_test.js @@ -0,0 +1,99 @@ +import * as ziba from "./ziba.js" + +export function test() { + testTransform() +} + +function testTransform() { + + const tests = [ + { + html:"", + expected:"", + }, + + + + { + html:'', + expected:'', + }, + + + + { + html:'apple', + expected:'apple', + }, + { + html:'banana', + expected:'banana', + }, + { + html:'cherry', + expected:'cherry', + }, + + + + { + html:'ONCE TWICE THRICE FOURCE', + expected:'ONCE TWICE THRICE FOURCE', + }, + + + + { + html:'once', + expected:'once', + }, + { + html:'twice', + expected:'twice', + }, + { + html:'thrice', + expected:'thrice', + }, + { + html:'fource', + expected:'fource', + }, + + + + { + html:'ONCE TWICE THRICE FOURCE', + expected:'ONCE TWICE THRICE FOURCE', + }, + ] + + + tests.forEach(function(test, testNumber){ + if (undefined === ziba.transform) { + console.error("[test-tramsform] For test", testNumber, "ziba.transform is undefined.") + return + } + + const html = test.html + const expected = test.expected + + const element = document.createElement("div") + element.innerHTML = html + ziba.transform(element) + + + const actual = element.innerHTML + + if (expected !== actual) { + console.error("[test-tramsform] For test №", testNumber, "the actual value is not what was expected.") + console.log("[test-tramsform] EXPECTED:", JSON.stringify(expected)) + console.log("[test-tramsform] ACTUAL: ", JSON.stringify(actual)) + console.log("[test-tramsform] HTML: ", JSON.stringify(html)) + return + } + + console.log("[test-tramsform] Test №", testNumber, "passed.") + }) + +}