本文整理匯總了TypeScript中@jupyterlab/codemirror/src/mode.Mode類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Mode類的具體用法?TypeScript Mode怎麽用?TypeScript Mode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Mode類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should add a spec loader', async () => {
let called = 0;
let loaded = 0;
Mode.addSpecLoader(async spec => {
called++;
if (spec.mode !== 'bar') {
return false;
}
loaded++;
return true;
}, 42);
CodeMirror.modeInfo.push(fakeMode('bar'));
let spec = await Mode.ensure('bar');
expect(called).to.equal(1);
expect(loaded).to.equal(1);
expect(spec.name).to.equal('BAR');
spec = await Mode.ensure('python');
expect(called).to.equal(1);
expect(loaded).to.equal(1);
try {
spec = await Mode.ensure('APL');
} catch (err) {
// apparently one cannot use webpack `require` in jest
}
expect(called).to.equal(2);
expect(loaded).to.equal(1);
});