forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportToHTML.test.ts
More file actions
50 lines (47 loc) · 2.3 KB
/
exportToHTML.test.ts
File metadata and controls
50 lines (47 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation. All rights reserved.
// tslint:disable: no-var-requires no-require-imports no-invalid-this no-any
import { assert } from 'chai';
import * as path from 'path';
import { CancellationTokenSource, Uri } from 'vscode';
import { ExportFormat, IExport } from '../../../client/datascience/export/types';
import { IDataScienceFileSystem } from '../../../client/datascience/types';
import { IExtensionTestApi } from '../../common';
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../constants';
import { closeActiveWindows, initialize } from '../../initialize';
suite('DataScience - Export HTML', () => {
let api: IExtensionTestApi;
suiteSetup(async function () {
this.timeout(10_000);
api = await initialize();
// Export to HTML tests require jupyter to run. Othewrise can't
// run any of our variable execution code
const isRollingBuild = process.env ? process.env.VSCODE_PYTHON_ROLLING !== undefined : false;
if (!isRollingBuild) {
// tslint:disable-next-line:no-console
console.log('Skipping Export to HTML tests. Requires python environment');
// tslint:disable-next-line:no-invalid-this
this.skip();
}
});
teardown(closeActiveWindows);
suiteTeardown(closeActiveWindows);
test('Export To HTML', async () => {
const fileSystem = api.serviceContainer.get<IDataScienceFileSystem>(IDataScienceFileSystem);
const exportToHTML = api.serviceContainer.get<IExport>(IExport, ExportFormat.html);
const file = await fileSystem.createTemporaryLocalFile('.html');
const target = Uri.file(file.filePath);
await file.dispose();
const token = new CancellationTokenSource();
await exportToHTML.export(
Uri.file(path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'datascience', 'export', 'test.ipynb')),
target,
token.token
);
assert.equal(await fileSystem.localFileExists(target.fsPath), true);
const fileContents = await fileSystem.readLocalFile(target.fsPath);
assert.include(fileContents, '<!DOCTYPE html>');
// this is the content of a cell
assert.include(fileContents, 'f6886df81f3d4023a2122cc3f55fdbec');
});
});