@ephox/bedrock-client
Advanced tools
Comparing version 9.6.1 to 10.0.0
@@ -5,3 +5,3 @@ declare const eq: (expected: any, actual: any, message?: string | (() => string) | undefined) => void; | ||
declare const succeeds: (f: () => void, message?: string | (() => string) | undefined) => void; | ||
declare const fail: (message?: string | (() => string) | undefined) => never; | ||
declare const fail: (message?: string | (() => string) | undefined) => void; | ||
export { eq, throws, throwsError, succeeds, fail }; |
@@ -0,3 +1,3 @@ | ||
import { TestLabel } from '@ephox/bedrock-common'; | ||
import * as Compare from '../core/Compare'; | ||
import { TestLabel } from './TestLabel'; | ||
var eq = function (expected, actual, message) { | ||
@@ -4,0 +4,0 @@ var result = Compare.compare(expected, actual); |
@@ -0,6 +1,6 @@ | ||
import { LoggedError, TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { after, afterEach, before, beforeEach, context, describe, it, specify, xcontext, xdescribe, xspecify, xit } from './Bdd'; | ||
import * as LegacyAssert from './LegacyAssert'; | ||
import * as NewAssert from './NewAssert'; | ||
import * as UnitTest from './UnitTest'; | ||
import { TestLabel } from './TestLabel'; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
export { LegacyAssert as assert, NewAssert as Assert, UnitTest, TestLabel, TestError }; | ||
export { before, beforeEach, after, afterEach, describe, xdescribe, context, xcontext, it, xit, specify, xspecify, LegacyAssert as assert, NewAssert as Assert, UnitTest, LoggedError, TestLabel, TestError }; |
@@ -0,7 +1,7 @@ | ||
import { LoggedError, TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { after, afterEach, before, beforeEach, context, describe, it, specify, xcontext, xdescribe, xspecify, xit } from './Bdd'; | ||
import * as LegacyAssert from './LegacyAssert'; | ||
import * as NewAssert from './NewAssert'; | ||
import * as UnitTest from './UnitTest'; | ||
import { TestLabel } from './TestLabel'; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
export { LegacyAssert as assert, NewAssert as Assert, UnitTest, TestLabel, TestError }; | ||
export { before, beforeEach, after, afterEach, describe, xdescribe, context, xcontext, it, xit, specify, xspecify, LegacyAssert as assert, NewAssert as Assert, UnitTest, LoggedError, TestLabel, TestError }; | ||
//# sourceMappingURL=Main.js.map |
@@ -0,3 +1,3 @@ | ||
import { TestLabel } from '@ephox/bedrock-common'; | ||
import { Testable } from '@ephox/dispute'; | ||
import { TestLabel } from './TestLabel'; | ||
declare const eq: <T>(message: TestLabel, expected: T, actual: T, tt?: Testable.Testable<T>) => void; | ||
@@ -7,3 +7,3 @@ declare const throws: (message: TestLabel, f: () => void, expected?: string | undefined) => void; | ||
declare const succeeds: (message: TestLabel, f: () => void) => void; | ||
declare const fail: (message: TestLabel) => never; | ||
declare const fail: (message: TestLabel) => void; | ||
export { eq, throws, throwsError, succeeds, fail }; |
@@ -1,4 +0,3 @@ | ||
import { Testable, Pprint } from '@ephox/dispute'; | ||
import { TestLabel } from './TestLabel'; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
import { TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { Pprint, Testable } from '@ephox/dispute'; | ||
var eq = function (message, expected, actual, tt) { | ||
@@ -5,0 +4,0 @@ if (tt === void 0) { tt = Testable.tAny; } |
@@ -1,6 +0,4 @@ | ||
import { TestLabel } from "./TestLabel"; | ||
import { TestLogs } from "./TestLogs"; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
import { Context, TestError, TestLabel, TestLogs } from '@ephox/bedrock-common'; | ||
declare type TestLogs = TestLogs.TestLogs; | ||
declare type TestError = TestError.TestError; | ||
export declare type HtmlDiffError = TestError.HtmlDiffAssertionError; | ||
export declare type SuccessCallback = () => void; | ||
@@ -10,9 +8,9 @@ export declare type TestThrowable = TestLabel | TestError; | ||
/** An asynchronous test with callbacks. */ | ||
export declare const asyncTest: (name: string, test: (success: SuccessCallback, failure: FailureCallback) => void) => void; | ||
export declare const asyncTest: (name: string, test: (this: Context, success: SuccessCallback, failure: FailureCallback) => void) => void; | ||
/** Migrate to asyncTest */ | ||
export declare const asynctest: (name: string, test: (success: SuccessCallback, failure: FailureCallback) => void) => void; | ||
export declare const asynctest: (name: string, test: (this: Context, success: SuccessCallback, failure: FailureCallback) => void) => void; | ||
/** A synchronous test that fails if an exception is thrown */ | ||
export declare const test: (name: string, test: () => void) => void; | ||
export declare const test: (name: string, test: (this: Context) => void) => void; | ||
/** Tests an async function (function that returns a Promise). */ | ||
export declare const promiseTest: (name: string, test: () => Promise<void>) => void; | ||
export declare const promiseTest: (name: string, test: (this: Context) => Promise<void>) => void; | ||
export {}; |
@@ -1,97 +0,10 @@ | ||
import { TestLogs } from "./TestLogs"; | ||
var Global = (function () { | ||
if (typeof window !== 'undefined') { | ||
return window; | ||
} | ||
else { | ||
return Function('return this;')(); | ||
} | ||
})(); | ||
var register = function (name, test) { | ||
if (typeof Global.__tests === 'undefined') { | ||
Global.__tests = []; | ||
} | ||
Global.__tests.push({ name: name, test: test }); | ||
}; | ||
var cleanStack = function (error, linesToRemove) { | ||
if (linesToRemove === void 0) { linesToRemove = 1; } | ||
if (error.stack === undefined) { | ||
return ''; | ||
} | ||
var lines = error.stack.split('\n'); | ||
var message = lines[0]; | ||
var stack = lines.slice(1 + linesToRemove); | ||
return message + '\n' + stack.join('\n'); | ||
}; | ||
var normalizeError = function (err) { | ||
if (typeof err === 'string') { | ||
// Create an error object, but strip the stack of the 2 latest calls as it'll | ||
// just be this function and the previous function that called this (ie asyncTest) | ||
var error = new Error(err); | ||
error.stack = cleanStack(error, 2); | ||
return error; | ||
} | ||
else if (typeof err === 'function') { | ||
return normalizeError(err()); | ||
} | ||
else { | ||
return err; | ||
} | ||
}; | ||
var processLog = function (logs) { | ||
var outputToStr = function (numIndent, entries) { | ||
var everything = []; | ||
var indentString = ''; | ||
for (var i = 0; i < numIndent; i++) { | ||
indentString += ' '; | ||
} | ||
var _loop_1 = function (i) { | ||
var entry = entries[i]; | ||
var output = (function () { | ||
var traceLines = entry.trace === null || typeof entry.trace !== 'string' ? [] : ['', '', ''].concat(entry.trace.split('\n')); | ||
if (entry.entries.length === 0) { | ||
if (entry.trace === null) { | ||
return [indentString + '* ' + entry.message]; | ||
} | ||
else { | ||
return [indentString + '* ' + entry.message].concat(traceLines); | ||
} | ||
} | ||
else { | ||
// We have entries ... let's format them. | ||
return [indentString + '* ' + entry.message].concat(outputToStr(numIndent + 2, entry.entries)).concat(traceLines); | ||
} | ||
})(); | ||
everything = everything.concat(output); | ||
}; | ||
for (var i = 0; i < entries.length; i++) { | ||
_loop_1(i); | ||
} | ||
return everything; | ||
}; | ||
return outputToStr(2, logs.history); | ||
}; | ||
var prepFailure = function (err, logs) { | ||
if (logs === void 0) { logs = TestLogs.emptyLogs(); } | ||
var normalizedErr = normalizeError(err); | ||
var failureMessage = processLog(logs); | ||
return { | ||
error: normalizedErr, | ||
logs: failureMessage, | ||
}; | ||
}; | ||
import { Failure } from '@ephox/bedrock-common'; | ||
import { it } from './Bdd'; | ||
/** An asynchronous test with callbacks. */ | ||
export var asyncTest = function (name, test) { | ||
register(name, function (success, failure) { | ||
try { | ||
test(success, function (err, logs) { | ||
if (logs === void 0) { logs = TestLogs.emptyLogs(); } | ||
var r = prepFailure(err, logs); | ||
failure(r); | ||
}); | ||
} | ||
catch (e) { | ||
var r = prepFailure(e, TestLogs.emptyLogs()); | ||
failure(r); | ||
} | ||
it(name, function (done) { | ||
test.call(this, function () { return done(); }, (function (err, logs) { | ||
var r = Failure.prepFailure(err, logs); | ||
done(r); | ||
})); | ||
}); | ||
@@ -103,19 +16,8 @@ }; | ||
export var test = function (name, test) { | ||
register(name, function (success, failure) { | ||
try { | ||
test(); | ||
success(); | ||
} | ||
catch (e) { | ||
var r = prepFailure(e); | ||
failure(r); | ||
} | ||
}); | ||
it(name, test); | ||
}; | ||
/** Tests an async function (function that returns a Promise). */ | ||
export var promiseTest = function (name, test) { | ||
return asyncTest(name, function (success, failure) { | ||
test().then(success).catch(failure); | ||
}); | ||
it(name, test); | ||
}; | ||
//# sourceMappingURL=UnitTest.js.map |
@@ -1,1 +0,1 @@ | ||
export declare const typeOf: (x: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "array"; | ||
export declare const typeOf: (x: any) => string; |
{ | ||
"name": "@ephox/bedrock-client", | ||
"version": "9.6.1", | ||
"version": "10.0.0", | ||
"author": "Tiny Technologies Inc", | ||
@@ -13,3 +13,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@ephox/bedrock-common": "^9.3.2", | ||
"@ephox/bedrock-common": "^10.0.0", | ||
"@ephox/dispute": "^1.0.3" | ||
@@ -28,3 +28,3 @@ }, | ||
}, | ||
"gitHead": "bcb55a764a10d8d64c490edb6d20aa7f3e10ea55" | ||
"gitHead": "5a3e35056d38b48b81503e7ee256276c3544cd02" | ||
} |
@@ -0,5 +1,5 @@ | ||
import { TestLabel } from '@ephox/bedrock-common'; | ||
import * as Compare from '../core/Compare'; | ||
import { TestLabel } from './TestLabel'; | ||
const eq = function (expected: any, actual: any, message?: TestLabel) { | ||
const eq = function (expected: any, actual: any, message?: TestLabel): void { | ||
const result = Compare.compare(expected, actual); | ||
@@ -11,3 +11,3 @@ if (!result.eq) { | ||
const throws = function (f: () => void, expected?: string, message?: TestLabel) { | ||
const throws = function (f: () => void, expected?: string, message?: TestLabel): void { | ||
const token = {}; | ||
@@ -29,3 +29,3 @@ | ||
const throwsError = function (f: () => void, expected?: string, message?: TestLabel) { | ||
const throwsError = function (f: () => void, expected?: string, message?: TestLabel): void { | ||
const token = {}; | ||
@@ -47,3 +47,3 @@ | ||
const succeeds = function (f: () => void, message?: TestLabel) { | ||
const succeeds = function (f: () => void, message?: TestLabel): void { | ||
try { | ||
@@ -56,3 +56,3 @@ f(); | ||
const fail = function (message?: TestLabel) { | ||
const fail = function (message?: TestLabel): void { | ||
throw new Error(TestLabel.asStringOr(message, () => 'Test failed')); | ||
@@ -59,0 +59,0 @@ }; |
@@ -0,7 +1,28 @@ | ||
import { LoggedError, TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { after, afterEach, before, beforeEach, context, describe, it, specify, xcontext, xdescribe, xspecify, xit } from './Bdd'; | ||
import * as LegacyAssert from './LegacyAssert'; | ||
import * as NewAssert from './NewAssert'; | ||
import * as UnitTest from './UnitTest'; | ||
import { TestLabel } from './TestLabel'; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
export { LegacyAssert as assert, NewAssert as Assert, UnitTest, TestLabel, TestError }; | ||
export { | ||
before, | ||
beforeEach, | ||
after, | ||
afterEach, | ||
describe, | ||
xdescribe, | ||
context, | ||
xcontext, | ||
it, | ||
xit, | ||
specify, | ||
xspecify, | ||
LegacyAssert as assert, | ||
NewAssert as Assert, | ||
UnitTest, | ||
LoggedError, | ||
TestLabel, | ||
TestError | ||
}; |
@@ -1,6 +0,5 @@ | ||
import { Testable, Pprint } from '@ephox/dispute'; | ||
import { TestLabel } from './TestLabel'; | ||
import { TestError } from '@ephox/bedrock-common'; | ||
import { TestError, TestLabel } from '@ephox/bedrock-common'; | ||
import { Pprint, Testable } from '@ephox/dispute'; | ||
const eq = function <T> (message: TestLabel, expected: T, actual: T, tt: Testable.Testable<T> = Testable.tAny) { | ||
const eq = function <T> (message: TestLabel, expected: T, actual: T, tt: Testable.Testable<T> = Testable.tAny): void { | ||
const result = tt.eq(expected, actual); | ||
@@ -15,3 +14,3 @@ if (!result) { | ||
const throws = function (message: TestLabel, f: () => void, expected?: string) { | ||
const throws = function (message: TestLabel, f: () => void, expected?: string): void { | ||
const token = {}; | ||
@@ -33,3 +32,3 @@ | ||
const throwsError = function (message: TestLabel, f: () => void, expected?: string) { | ||
const throwsError = function (message: TestLabel, f: () => void, expected?: string): void { | ||
const token = {}; | ||
@@ -51,3 +50,3 @@ | ||
const succeeds = function (message: TestLabel, f: () => void) { | ||
const succeeds = function (message: TestLabel, f: () => void): void { | ||
try { | ||
@@ -60,3 +59,3 @@ f(); | ||
const fail = function (message: TestLabel) { | ||
const fail = function (message: TestLabel): void { | ||
throw new Error('Test failed\n' + TestLabel.asString(message)); | ||
@@ -63,0 +62,0 @@ }; |
@@ -1,10 +0,7 @@ | ||
import { TestLabel } from "./TestLabel"; | ||
import { TestLogEntry, TestLogs } from "./TestLogs"; | ||
import { TestError, LoggedError } from '@ephox/bedrock-common'; | ||
import { Context, Failure, TestError, TestLabel, TestLogs } from '@ephox/bedrock-common'; | ||
import { it } from './Bdd'; | ||
type TestLogs = TestLogs.TestLogs; | ||
type TestError = TestError.TestError; | ||
type LoggedError = LoggedError.LoggedError; | ||
export type HtmlDiffError = TestError.HtmlDiffAssertionError; | ||
export type SuccessCallback = () => void; | ||
@@ -14,98 +11,9 @@ export type TestThrowable = TestLabel | TestError; | ||
const Global = (function () { | ||
if (typeof window !== 'undefined') { | ||
return window; | ||
} else { | ||
return Function('return this;')(); | ||
} | ||
})(); | ||
const register = (name: string, test: (success: () => void, failure: (e: LoggedError) => void) => void) => { | ||
if (typeof Global.__tests === 'undefined') { | ||
Global.__tests = []; | ||
} | ||
Global.__tests.push({name: name, test: test}); | ||
}; | ||
const cleanStack = (error: Error, linesToRemove = 1) => { | ||
if (error.stack === undefined) { | ||
return ''; | ||
} | ||
const lines = error.stack.split('\n'); | ||
const message = lines[0]; | ||
const stack = lines.slice(1 + linesToRemove); | ||
return message + '\n' + stack.join('\n'); | ||
}; | ||
const normalizeError = (err: TestThrowable): TestError => { | ||
if (typeof err === 'string') { | ||
// Create an error object, but strip the stack of the 2 latest calls as it'll | ||
// just be this function and the previous function that called this (ie asyncTest) | ||
const error = new Error(err); | ||
error.stack = cleanStack(error, 2); | ||
return error; | ||
} else if (typeof err === 'function') { | ||
return normalizeError(err()); | ||
} else { | ||
return err; | ||
} | ||
}; | ||
const processLog = (logs: TestLogs): string[] => { | ||
const outputToStr = function (numIndent: number, entries: TestLogEntry[]) { | ||
let everything: string[] = [ ]; | ||
let indentString = ''; | ||
for (let i = 0; i < numIndent; i++) { | ||
indentString += ' '; | ||
} | ||
for (let i = 0; i < entries.length; i++) { | ||
const entry = entries[i]; | ||
const output = (() => { | ||
const traceLines = entry.trace === null || typeof entry.trace !== 'string' ? [ ] : [ '', '', '' ].concat(entry.trace.split('\n')); | ||
if (entry.entries.length === 0) { | ||
if (entry.trace === null) { | ||
return [ indentString + '* ' + entry.message ]; | ||
} else { | ||
return [ indentString + '* ' + entry.message ].concat(traceLines); | ||
} | ||
} else { | ||
// We have entries ... let's format them. | ||
return [ indentString + '* ' + entry.message ].concat( | ||
outputToStr(numIndent + 2, entry.entries) | ||
).concat(traceLines); | ||
} | ||
})(); | ||
everything = everything.concat(output) | ||
} | ||
return everything; | ||
}; | ||
return outputToStr(2, logs.history); | ||
}; | ||
const prepFailure = (err: TestThrowable, logs: TestLogs = TestLogs.emptyLogs()): LoggedError => { | ||
const normalizedErr = normalizeError(err); | ||
const failureMessage = processLog(logs); | ||
return { | ||
error: normalizedErr, | ||
logs: failureMessage, | ||
} | ||
}; | ||
/** An asynchronous test with callbacks. */ | ||
export const asyncTest = (name: string, test: (success: SuccessCallback, failure: FailureCallback) => void) => { | ||
register(name, function (success: () => void, failure: (e: LoggedError) => void) { | ||
try { | ||
test(success, function (err: TestThrowable, logs: TestLogs = TestLogs.emptyLogs()) { | ||
const r = prepFailure(err, logs); | ||
failure(r); | ||
}); | ||
} catch (e) { | ||
const r = prepFailure(e, TestLogs.emptyLogs()); | ||
failure(r); | ||
} | ||
export const asyncTest = (name: string, test: (this: Context, success: SuccessCallback, failure: FailureCallback) => void): void => { | ||
it(name, function (done) { | ||
test.call(this, () => done(), ((err, logs) => { | ||
const r = Failure.prepFailure(err, logs); | ||
done(r); | ||
})); | ||
}); | ||
@@ -118,18 +26,9 @@ }; | ||
/** A synchronous test that fails if an exception is thrown */ | ||
export const test = (name: string, test: () => void) => { | ||
register(name, function (success: () => void, failure: (e: LoggedError) => void) { | ||
try { | ||
test(); | ||
success(); | ||
} catch (e) { | ||
const r = prepFailure(e); | ||
failure(r); | ||
} | ||
}); | ||
export const test = (name: string, test: (this: Context) => void): void => { | ||
it(name, test); | ||
}; | ||
/** Tests an async function (function that returns a Promise). */ | ||
export const promiseTest = (name: string, test: () => Promise<void>) => | ||
asyncTest(name, (success, failure) => { | ||
test().then(success).catch(failure); | ||
}); | ||
export const promiseTest = (name: string, test: (this: Context) => Promise<void>): void => { | ||
it(name, test); | ||
}; |
@@ -9,3 +9,3 @@ import * as Type from './Type'; | ||
const Obj = { | ||
keys: (obj: object): string[] => | ||
keys: (obj: Record<string, unknown>): string[] => | ||
Object.keys(obj) | ||
@@ -20,6 +20,6 @@ }; | ||
const pass = (): Comparison => | ||
({eq: true, why: () => ''}); | ||
({ eq: true, why: () => '' }); | ||
const fail = (why: () => string): Comparison => | ||
({eq: false, why: why}); | ||
({ eq: false, why }); | ||
@@ -53,3 +53,3 @@ const failCompare = (x: any, y: any, prefix?: string): Comparison => { | ||
const sortedKeys = (o: object) => | ||
const sortedKeys = (o: Record<string, unknown>) => | ||
sortArray(Obj.keys(o)); | ||
@@ -56,0 +56,0 @@ |
@@ -1,2 +0,2 @@ | ||
export const typeOf = function (x: any) { | ||
export const typeOf = function (x: any): string { | ||
if (x === null) { | ||
@@ -3,0 +3,0 @@ return 'null'; |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
0
43835
38
763
+ Added@ephox/bedrock-common@10.1.0(transitive)
+ Addeddiff@4.0.2(transitive)
- Removed@ephox/bedrock-common@9.3.2(transitive)