本文整理匯總了TypeScript中assert.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript assert.default方法的具體用法?TypeScript assert.default怎麽用?TypeScript assert.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類assert
的用法示例。
在下文中一共展示了assert.default方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: RegExp
test('areFunctions', () => {
assert(!types.areFunctions());
assert(!types.areFunctions(null));
assert(!types.areFunctions('foo'));
assert(!types.areFunctions(5));
assert(!types.areFunctions(true));
assert(!types.areFunctions([]));
assert(!types.areFunctions([1, 2, '3']));
assert(!types.areFunctions({}));
assert(!types.areFunctions({ foo: 'bar' }));
assert(!types.areFunctions(/test/));
assert(!types.areFunctions(new RegExp('')));
assert(!types.areFunctions(new Date()));
assert(!types.areFunctions(assert, ''));
assert(types.areFunctions(assert));
assert(types.areFunctions(assert, assert));
assert(types.areFunctions(function foo() { /**/ }));
});
示例2: function
test('CamelCaseFilter - #19256', function () {
assert(matchesCamelCase('Debug Console', 'Open: Debug Console'));
assert(matchesCamelCase('Debug console', 'Open: Debug Console'));
assert(matchesCamelCase('debug console', 'Open: Debug Console'));
});
示例3: Name
test('Validate File Name (For Create)', function () {
const d = new Date().getTime();
const s = createStat('/path/to/stat', 'sName', true, true, 8096, d);
const sChild = createStat('/path/to/stat/alles.klar', 'alles.klar', true, true, 8096, d);
s.addChild(sChild);
assert(validateFileName(s, null) !== null);
assert(validateFileName(s, '') !== null);
assert(validateFileName(s, ' ') !== null);
assert(validateFileName(s, 'Read Me') === null, 'name containing space');
if (isWindows) {
assert(validateFileName(s, 'foo:bar') !== null);
assert(validateFileName(s, 'foo*bar') !== null);
assert(validateFileName(s, 'foo?bar') !== null);
assert(validateFileName(s, 'foo<bar') !== null);
assert(validateFileName(s, 'foo>bar') !== null);
assert(validateFileName(s, 'foo|bar') !== null);
}
assert(validateFileName(s, 'alles.klar') !== null);
assert(validateFileName(s, '.foo') === null);
assert(validateFileName(s, 'foo.bar') === null);
assert(validateFileName(s, 'foo') === null);
});
示例4: Event
test('File Change Event (with stats)', function () {
let d = new Date().toUTCString();
let s1 = new FileStat(toResource('/path/to/sName'), false, false, 'sName', 8096 /* Size */, d);
let s2 = new FileStat(toResource('/path/to/sName'), false, false, 'sName', 16000 /* Size */, d);
let s3 = new FileStat(toResource('/path/to/sNameMoved'), false, false, 'sNameMoved', 8096 /* Size */, d);
// Got Added
let event = new LocalFileChangeEvent(null, s1);
assert(event.gotAdded());
assert(!event.gotDeleted());
assert(!event.gotUpdated());
assert(!event.gotMoved());
// Got Removed
event = new LocalFileChangeEvent(s1, null);
assert(!event.gotAdded());
assert(event.gotDeleted());
assert(!event.gotUpdated());
assert(!event.gotMoved());
// Got Moved
event = new LocalFileChangeEvent(s3, s1);
assert(!event.gotAdded());
assert(!event.gotDeleted());
assert(!event.gotUpdated());
assert(event.gotMoved());
// Got Updated
event = new LocalFileChangeEvent(s2, s1);
assert(!event.gotAdded());
assert(!event.gotDeleted());
assert(event.gotUpdated());
assert(!event.gotMoved());
// No Change
event = new LocalFileChangeEvent(s1, s1);
assert(!event.gotAdded());
assert(!event.gotDeleted());
assert(!event.gotUpdated());
assert(!event.gotMoved());
});
示例5: function
IntentSchema.fromFile("test/alexa/resources/IntentSchemaNonExistent.json", function (schema: IntentSchema, error?: string) {
assert(error.indexOf("not found") !== -1);
done();
});
示例6: assert
.catch(error => {
assert(error.code === "ERR_ASSERTION" || error.name === "AssertionError");
});
示例7: function
this.spoken = function (utterance: string, callback: any) {
assert(sessionRemoved);
done();
};
示例8: finished
TestMeta,
TestReporter,
TestResult
} from '../src';
const reporter: TestReporter = {
finished(_: TestResult[]): void {
// ...
},
started(_: Test[]): void {
// ...
},
testFinished(result: TestResult): void {
if (typeof result.error !== 'undefined') {
const e: Error = result.error;
assert(e);
}
},
testStarted(test: Test): void {
const fn: TestFn = test.fn;
const meta: TestMeta = test.meta;
assert(fn);
assert(meta);
}
}
assert(reporter);
示例9: assert
(message) => assert(this.validator(input).indexOf(message) > -1,
`Expected error of ${JSON.stringify(this.settings)} on \`${input}\` to contain ${message}. Got ${this.validator(input)}.`)
示例10:
test('removeClass', () => {
let element = document.createElement('div');
element.className = 'foobar boo far';
dom.removeClass(element, 'boo');
assert(dom.hasClass(element, 'far'));
assert(!dom.hasClass(element, 'boo'));
assert(dom.hasClass(element, 'foobar'));
assert.equal(element.className, 'foobar far');
element = document.createElement('div');
element.className = 'foobar boo far';
dom.removeClass(element, 'far');
assert(!dom.hasClass(element, 'far'));
assert(dom.hasClass(element, 'boo'));
assert(dom.hasClass(element, 'foobar'));
assert.equal(element.className, 'foobar boo');
dom.removeClass(element, 'boo');
assert(!dom.hasClass(element, 'far'));
assert(!dom.hasClass(element, 'boo'));
assert(dom.hasClass(element, 'foobar'));
assert.equal(element.className, 'foobar');
dom.removeClass(element, 'foobar');
assert(!dom.hasClass(element, 'far'));
assert(!dom.hasClass(element, 'boo'));
assert(!dom.hasClass(element, 'foobar'));
assert.equal(element.className, '');
});