disable thumbnail test. add test for flat dom

This commit is contained in:
ansuz
2017-10-27 11:01:22 +02:00
parent 02cd7e5b58
commit df1a700cb2
2 changed files with 22 additions and 4 deletions

View File

@@ -7,7 +7,8 @@ define([
'/drive/tests.js',
'/common/test.js',
'/common/common-thumbnail.js',
], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test, Thumb) {
'/common/flat-dom.js',
], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test, Thumb, Flat) {
window.Hyperjson = Hyperjson;
window.TextPatcher = TextPatcher;
window.Sortify = Sortify;
@@ -241,6 +242,7 @@ define([
return cb(true);
}, "version 2 hash failed to parse correctly");
/*
assert(function (cb) {
var getBlob = function (url, cb) {
var xhr = new XMLHttpRequest();
@@ -266,9 +268,21 @@ define([
});
});
});
*/
Drive.test(assert);
assert(function (cb) {
// extract dom elements into a flattened JSON representation
var flat = Flat.fromDOM(document.body);
// recreate a _mostly_ equivalent DOM
var dom = Flat.toDOM(flat);
// assume we don't care about comments
var bodyText = document.body.outerHTML.replace(/<!\-\-[\s\S]*?\-\->/g, '')
// check for equality
cb(dom.outerHTML === bodyText);
});
var swap = function (str, dict) {
return str.replace(/\{\{(.*?)\}\}/g, function (all, key) {
return typeof dict[key] !== 'undefined'? dict[key] : all;