@ephox/bedrock-client
Advanced tools
Comparing version 14.1.1 to 15.0.0-alpha.6
import { TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { Pprint, Testable } from '@ephox/dispute'; | ||
var eq = function (message, expected, actual, tt) { | ||
if (tt === void 0) { tt = Testable.tAny; } | ||
var result = tt.eq(expected, actual); | ||
const eq = (message, expected, actual, tt = Testable.tAny) => { | ||
const result = tt.eq(expected, actual); | ||
if (!result) { | ||
var sMessage = TestLabel.asString(message); | ||
var ppExpected = Pprint.render(expected, tt); | ||
var ppActual = Pprint.render(actual, tt); | ||
const sMessage = TestLabel.asString(message); | ||
const ppExpected = Pprint.render(expected, tt); | ||
const ppActual = Pprint.render(actual, tt); | ||
throw TestError.pprintAssertionError(sMessage, ppExpected, ppActual); | ||
} | ||
}; | ||
var throws = function (message, f, expected) { | ||
var token = {}; | ||
const throws = (message, f, expected) => { | ||
const token = {}; | ||
try { | ||
@@ -29,4 +28,4 @@ f(); | ||
}; | ||
var throwsError = function (message, f, expected) { | ||
var token = {}; | ||
const throwsError = (message, f, expected) => { | ||
const token = {}; | ||
try { | ||
@@ -46,3 +45,3 @@ f(); | ||
}; | ||
var succeeds = function (message, f) { | ||
const succeeds = (message, f) => { | ||
try { | ||
@@ -55,3 +54,3 @@ f(); | ||
}; | ||
var fail = function (message) { | ||
const fail = (message) => { | ||
throw new Error('Test failed\n' + TestLabel.asString(message)); | ||
@@ -58,0 +57,0 @@ }; |
import { Global } from '@ephox/bedrock-common'; | ||
var globals = Global; | ||
var before = globals.before, beforeEach = globals.beforeEach, after = globals.after, afterEach = globals.afterEach, describe = globals.describe, xdescribe = globals.xdescribe, context = globals.context, xcontext = globals.xcontext, it = globals.it, xit = globals.xit, specify = globals.specify, xspecify = globals.xspecify; | ||
const globals = Global; | ||
const { before, beforeEach, after, afterEach, describe, xdescribe, context, xcontext, it, xit, specify, xspecify } = globals; | ||
export { before, beforeEach, after, afterEach, describe, xdescribe, context, xcontext, it, xit, specify, xspecify }; | ||
//# sourceMappingURL=Bdd.js.map |
import { Failure } from '@ephox/bedrock-common'; | ||
import { it } from './Bdd'; | ||
/** An asynchronous test with callbacks. */ | ||
export var asyncTest = function (name, test) { | ||
export const asyncTest = (name, test) => { | ||
it(name, function (done) { | ||
test.call(this, function () { return done(); }, (function (err, logs) { | ||
var r = Failure.prepFailure(err, logs); | ||
test.call(this, () => done(), ((err, logs) => { | ||
const r = Failure.prepFailure(err, logs); | ||
done(r); | ||
@@ -13,11 +13,11 @@ })); | ||
/** Migrate to asyncTest */ | ||
export var asynctest = asyncTest; | ||
export const asynctest = asyncTest; | ||
/** A synchronous test that fails if an exception is thrown */ | ||
export var test = function (name, test) { | ||
export const test = (name, test) => { | ||
it(name, test); | ||
}; | ||
/** Tests an async function (function that returns a Promise). */ | ||
export var promiseTest = function (name, test) { | ||
export const promiseTest = (name, test) => { | ||
it(name, test); | ||
}; | ||
//# sourceMappingURL=UnitTest.js.map |
import { Type } from '@ephox/bedrock-common'; | ||
var Arr = { | ||
contains: function (values, value) { | ||
return values.indexOf(value) > -1; | ||
} | ||
const Arr = { | ||
contains: (values, value) => values.indexOf(value) > -1 | ||
}; | ||
var Obj = { | ||
keys: function (obj) { | ||
return Object.keys(obj); | ||
} | ||
const Obj = { | ||
keys: (obj) => Object.keys(obj) | ||
}; | ||
var pass = function () { | ||
return ({ eq: true, why: function () { return ''; }, message: function () { return ''; } }); | ||
const pass = () => ({ eq: true, why: () => '', message: () => '' }); | ||
const fail = (why) => ({ eq: false, why, message: why }); | ||
const failCompare = (x, y, prefix) => { | ||
return fail(() => (prefix || 'Values were different') + ': [' + String(x) + '] vs [' + String(y) + ']'); | ||
}; | ||
var fail = function (why) { | ||
return ({ eq: false, why: why, message: why }); | ||
}; | ||
var failCompare = function (x, y, prefix) { | ||
return fail(function () { return (prefix || 'Values were different') + ': [' + String(x) + '] vs [' + String(y) + ']'; }); | ||
}; | ||
var isEquatableType = function (x) { | ||
return Arr.contains(['undefined', 'boolean', 'number', 'string', 'function', 'xml', 'null'], x); | ||
}; | ||
var compareArrays = function (x, y) { | ||
const isEquatableType = (x) => Arr.contains(['undefined', 'boolean', 'number', 'string', 'function', 'xml', 'null'], x); | ||
const compareArrays = (x, y) => { | ||
if (x.length !== y.length) { | ||
return failCompare(x.length, y.length, 'Array lengths were different'); | ||
} | ||
var _loop_1 = function (i) { | ||
var result = doCompare(x[i], y[i]); | ||
for (let i = 0; i < x.length; i++) { | ||
const result = doCompare(x[i], y[i]); | ||
if (!result.eq) { | ||
return { value: fail(function () { return 'Array elements ' + i + ' were different: ' + result.why(); }) }; | ||
return fail(() => 'Array elements ' + i + ' were different: ' + result.why()); | ||
} | ||
}; | ||
for (var i = 0; i < x.length; i++) { | ||
var state_1 = _loop_1(i); | ||
if (typeof state_1 === "object") | ||
return state_1.value; | ||
} | ||
return pass(); | ||
}; | ||
var sortArray = function (x) { | ||
var y = x.slice(); | ||
const sortArray = (x) => { | ||
const y = x.slice(); | ||
y.sort(); | ||
return y; | ||
}; | ||
var sortedKeys = function (o) { | ||
return sortArray(Obj.keys(o)); | ||
}; | ||
var compareObjects = function (x, y) { | ||
var constructorX = x.constructor; | ||
var constructorY = y.constructor; | ||
const sortedKeys = (o) => sortArray(Obj.keys(o)); | ||
const compareObjects = (x, y) => { | ||
const constructorX = x.constructor; | ||
const constructorY = y.constructor; | ||
if (constructorX !== constructorY) { | ||
return failCompare(constructorX, constructorY, 'Constructors were different'); | ||
} | ||
var keysX = sortedKeys(x); | ||
var keysY = sortedKeys(y); | ||
var keysResult = compareArrays(keysX, keysY); | ||
const keysX = sortedKeys(x); | ||
const keysY = sortedKeys(y); | ||
const keysResult = compareArrays(keysX, keysY); | ||
if (!keysResult.eq) { | ||
return failCompare(JSON.stringify(keysX), JSON.stringify(keysY), 'Object keys were different'); | ||
} | ||
var _loop_2 = function (i) { | ||
for (const i in x) { | ||
if (x.hasOwnProperty(i)) { | ||
var xValue = x[i]; | ||
var yValue = y[i]; | ||
var valueResult_1 = doCompare(xValue, yValue); | ||
if (!valueResult_1.eq) { | ||
return { value: fail(function () { return 'Objects were different for key: [' + i + ']: ' + valueResult_1.why(); }) }; | ||
const xValue = x[i]; | ||
const yValue = y[i]; | ||
const valueResult = doCompare(xValue, yValue); | ||
if (!valueResult.eq) { | ||
return fail(() => 'Objects were different for key: [' + i + ']: ' + valueResult.why()); | ||
} | ||
} | ||
}; | ||
for (var i in x) { | ||
var state_2 = _loop_2(i); | ||
if (typeof state_2 === "object") | ||
return state_2.value; | ||
} | ||
return pass(); | ||
}; | ||
var doCompare = function (x, y) { | ||
const doCompare = (x, y) => { | ||
if (x === y) | ||
return pass(); | ||
var typeX = Type.typeOf(x); | ||
var typeY = Type.typeOf(y); | ||
const typeX = Type.typeOf(x); | ||
const typeY = Type.typeOf(y); | ||
if (typeX !== typeY) | ||
@@ -94,3 +72,3 @@ return failCompare(typeX, typeY, 'Types were different'); | ||
else if (typeX === 'array') { | ||
var arrayResult = compareArrays(x, y); | ||
const arrayResult = compareArrays(x, y); | ||
if (!arrayResult.eq) | ||
@@ -100,3 +78,3 @@ return arrayResult; | ||
else if (typeX === 'object') { | ||
var objectResult = compareObjects(x, y); | ||
const objectResult = compareObjects(x, y); | ||
if (!objectResult.eq) | ||
@@ -107,8 +85,8 @@ return objectResult; | ||
}; | ||
export var compare = function (x, y) { | ||
var result = doCompare(x, y); | ||
var bar = '-----------------------------------------------------------------------'; | ||
export const compare = (x, y) => { | ||
const result = doCompare(x, y); | ||
const bar = '-----------------------------------------------------------------------'; | ||
return { | ||
eq: result.eq, | ||
why: function () { return result.why() + '\n' + bar + '\n' + JSON.stringify(x) + '\n' + bar + '\n' + JSON.stringify(y) + '\n' + bar + '\n'; }, | ||
why: () => result.why() + '\n' + bar + '\n' + JSON.stringify(x) + '\n' + bar + '\n' + JSON.stringify(y) + '\n' + bar + '\n', | ||
message: result.why | ||
@@ -115,0 +93,0 @@ }; |
@@ -6,10 +6,10 @@ import { Testable } from '@ephox/dispute'; | ||
import { Assert } from '../../../main/ts/api/Main'; | ||
var tArray = Testable.tArray, tString = Testable.tString; | ||
describe('Assert.eq', function () { | ||
it('does not throw when assertion passes', function () { | ||
fc.assert(fc.property(fc.integer(), function (i) { | ||
const { tArray, tString } = Testable; | ||
describe('Assert.eq', () => { | ||
it('does not throw when assertion passes', () => { | ||
fc.assert(fc.property(fc.integer(), (i) => { | ||
Assert.eq('blah', i, i); | ||
return true; | ||
})); | ||
fc.assert(fc.property(fc.array(fc.string()), function (xs) { | ||
fc.assert(fc.property(fc.array(fc.string()), (xs) => { | ||
Assert.eq('blah', xs, xs); | ||
@@ -21,8 +21,8 @@ Assert.eq('blah', xs, xs.slice()); | ||
}); | ||
it('throws when assertion fails', function () { | ||
Assert.throws('throws', function () { | ||
it('throws when assertion fails', () => { | ||
Assert.throws('throws', () => { | ||
Assert.eq('blah', 'a', 'b'); | ||
}); | ||
}); | ||
it('throws a PprintAssertionError', function () { | ||
it('throws a PprintAssertionError', () => { | ||
try { | ||
@@ -32,3 +32,3 @@ Assert.eq('blah', 'a', 'b'); | ||
catch (e) { | ||
var ee = e; | ||
const ee = e; | ||
chai.assert.deepEqual(ee.message, 'blah'); | ||
@@ -35,0 +35,0 @@ chai.assert.deepEqual(ee.diff.actual, '"b"'); |
{ | ||
"name": "@ephox/bedrock-client", | ||
"version": "14.1.1", | ||
"version": "15.0.0-alpha.6", | ||
"author": "Tiny Technologies Inc", | ||
@@ -13,3 +13,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@ephox/bedrock-common": "^14.1.1", | ||
"@ephox/bedrock-common": "^15.0.0-alpha.6", | ||
"@ephox/dispute": "^1.0.3" | ||
@@ -28,3 +28,3 @@ }, | ||
}, | ||
"gitHead": "974910a70dab2c6311f55ca3e003647b6218475b" | ||
"gitHead": "45fb4a368bd8b4a24f83045854ec39a62c48b5a9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
30906
522
2
+ Added@ephox/bedrock-common@15.0.0(transitive)
- Removed@ephox/bedrock-common@14.1.1(transitive)