all tests passing

pull/3539/head
Richard Harris 6 years ago
parent 12d5126e32
commit 24be60744f

@ -1,5 +1,5 @@
import { b, x, p } from 'code-red';
import { stringify, escape } from '../utils/stringify';
import { escape } from '../utils/stringify';
import Component from '../Component';
import Renderer from './Renderer';
import { CompileOptions } from '../../interfaces';
@ -26,7 +26,7 @@ export default function dom(
const body = [];
if (component.compile_options.dev && component.file) {
if (renderer.file_var) {
body.push(b`const ${renderer.file_var} = "${component.file}";`);
}

@ -1,3 +1,29 @@
export function deepEqual(a, b, message) {
if (!is_equal(a, b)) {
throw new Error(message || `Expected ${JSON.stringify(a)} to equal ${JSON.stringify(b)}`);
}
}
function is_equal(a, b) {
if (a && typeof a === 'object') {
const is_array = Array.isArray(a);
if (Array.isArray(b) !== is_array) return false;
if (is_array) {
if (a.length !== b.length) return false;
return a.every((value, i) => is_equal(value, b[i]));
}
const a_keys = Object.keys(a).sort();
const b_keys = Object.keys(b).sort();
if (a_keys.join(',') !== b_keys.join(',')) return false;
return a_keys.every(key => is_equal(a[key], b[key]));
}
return a === b;
}
export function equal(a, b, message) {
if (a != b) throw new Error(message || `Expected ${a} to equal ${b}`);
}

@ -109,6 +109,11 @@ describe('custom-elements', function() {
console[type](...args);
});
page.on('error', error => {
console.log('>>> an error happened');
console.error(error);
});
try {
await page.goto('http://localhost:6789');

@ -11,8 +11,9 @@ export default function (target) {
target.innerHTML = '<my-app foo=yes />';
assert.equal(warnings.length, 1);
assert.equal(warnings[0], `<my-app> was created without expected prop 'bar'`);
assert.deepEqual(warnings, [
`<my-app> was created without expected prop 'bar'`
]);
console.warn = warn;
}
Loading…
Cancel
Save