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