20 lines
852 B
TypeScript
20 lines
852 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
const codePath = path.join(process.cwd(), 'dist', 'universal', 'Code.js');
|
|
|
|
describe('GAS bundle wrappers', () => {
|
|
it.skipIf(!fs.existsSync(codePath))('объявляет onOpen и пункты меню на верхнем уровне файла', () => {
|
|
const code = fs.readFileSync(codePath, 'utf8');
|
|
const topLevel = (name) =>
|
|
new RegExp(`^function ${name}\\(\\) \\{ return \\(__gas\\.default \\|\\| __gas\\)\\.${name}\\.apply\\(this, arguments\\); \\}$`, 'm');
|
|
|
|
expect(code).toMatch(topLevel('onOpen'));
|
|
expect(code).toMatch(topLevel('createBigSmallTasksReport'));
|
|
expect(code).toMatch(topLevel('saveDateRange'));
|
|
expect(code.startsWith('const __gas = ')).toBe(true);
|
|
expect(code).not.toMatch(/\bvar\b/);
|
|
});
|
|
});
|