mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2024-11-24 00:55:00 +03:00
Поправил тесты
This commit is contained in:
parent
af73897b00
commit
8549f412a7
@ -15,8 +15,7 @@ describe('_generateCadesFn', () => {
|
|||||||
console.log('hello from named function');
|
console.log('hello from named function');
|
||||||
}),
|
}),
|
||||||
).toEqual(
|
).toEqual(
|
||||||
`(function anonymous(
|
`(function anonymous() {
|
||||||
) {
|
|
||||||
|
|
||||||
console.log('hello from named function');
|
console.log('hello from named function');
|
||||||
|
|
||||||
@ -26,8 +25,7 @@ describe('_generateCadesFn', () => {
|
|||||||
|
|
||||||
test('generates function body from arrow function callback', () => {
|
test('generates function body from arrow function callback', () => {
|
||||||
expect(_generateCadesFn(() => console.log('hello from arrow function'))).toEqual(
|
expect(_generateCadesFn(() => console.log('hello from arrow function'))).toEqual(
|
||||||
`(function anonymous(
|
`(function anonymous() {
|
||||||
) {
|
|
||||||
return console.log('hello from arrow function');
|
return console.log('hello from arrow function');
|
||||||
})();//# sourceURL=crypto-pro_dynamicFn.js`,
|
})();//# sourceURL=crypto-pro_dynamicFn.js`,
|
||||||
);
|
);
|
||||||
@ -43,8 +41,7 @@ describe('_generateCadesFn', () => {
|
|||||||
void (__cadesAsyncToken__ + cadesBarNoMatterWhat.whateverMethod(cadesFoo));
|
void (__cadesAsyncToken__ + cadesBarNoMatterWhat.whateverMethod(cadesFoo));
|
||||||
}),
|
}),
|
||||||
).toEqual(
|
).toEqual(
|
||||||
`(function anonymous(
|
`(function anonymous() {
|
||||||
) {
|
|
||||||
|
|
||||||
var cadesFoo = cadesplugin.CreateObject('CADESCOM.Foo');
|
var cadesFoo = cadesplugin.CreateObject('CADESCOM.Foo');
|
||||||
var cadesBar = cadesplugin.CreateObject('CAdESCOM.Bar');
|
var cadesBar = cadesplugin.CreateObject('CAdESCOM.Bar');
|
||||||
@ -72,8 +69,7 @@ describe('_generateCadesFn', () => {
|
|||||||
void (__cadesAsyncToken__ + cadesBarNoMatterWhat.whateverMethod(cadesFoo));
|
void (__cadesAsyncToken__ + cadesBarNoMatterWhat.whateverMethod(cadesFoo));
|
||||||
}),
|
}),
|
||||||
).toEqual(
|
).toEqual(
|
||||||
`cadesplugin.async_spawn(function* anonymous(
|
`cadesplugin.async_spawn(function* anonymous() {
|
||||||
) {
|
|
||||||
|
|
||||||
var cadesFoo = yield cadesplugin.CreateObjectAsync('CADESCOM.Foo');
|
var cadesFoo = yield cadesplugin.CreateObjectAsync('CADESCOM.Foo');
|
||||||
var cadesBar = yield cadesplugin.CreateObjectAsync('CAdESCOM.Bar');
|
var cadesBar = yield cadesplugin.CreateObjectAsync('CAdESCOM.Bar');
|
||||||
|
@ -13,9 +13,14 @@ export const _generateCadesFn = (callback: Function): string => {
|
|||||||
const callbackLiteral = String(callback);
|
const callbackLiteral = String(callback);
|
||||||
const callbackArguments = callbackLiteral.match(/^function[\s\w]*?\((.*?)\)/)?.[1] || '';
|
const callbackArguments = callbackLiteral.match(/^function[\s\w]*?\((.*?)\)/)?.[1] || '';
|
||||||
const callbackBody = callbackLiteral.replace(/^.*?{([\s\S]*?)}$/, '$1');
|
const callbackBody = callbackLiteral.replace(/^.*?{([\s\S]*?)}$/, '$1');
|
||||||
let crossEnvCallbackLiteral = String(
|
let crossEnvCallbackLiteral;
|
||||||
new (cadesGeneratorsAPI ? getGeneratorConstructor() : Function)(callbackArguments, callbackBody),
|
if (callbackArguments) {
|
||||||
);
|
crossEnvCallbackLiteral = String(
|
||||||
|
new (cadesGeneratorsAPI ? getGeneratorConstructor() : Function)(callbackArguments, callbackBody),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
crossEnvCallbackLiteral = String(new (cadesGeneratorsAPI ? getGeneratorConstructor() : Function)(callbackBody));
|
||||||
|
}
|
||||||
|
|
||||||
crossEnvCallbackLiteral = crossEnvCallbackLiteral.replace(
|
crossEnvCallbackLiteral = crossEnvCallbackLiteral.replace(
|
||||||
/\w+?\.__createCadesPluginObject__(\([\s\S]*?\))/gm,
|
/\w+?\.__createCadesPluginObject__(\([\s\S]*?\))/gm,
|
||||||
|
Loading…
Reference in New Issue
Block a user