Register additional editor overrides when adding new notebook file types (#17708)

* Also standardized file extension contributions to always start with a period, and to always do lower case string comparisons for file extensions.
This commit is contained in:
Cory Rivera
2021-11-19 09:14:41 -08:00
committed by GitHub
parent 09666bc4e8
commit 8e04d3992a
8 changed files with 64 additions and 50 deletions

View File

@@ -221,17 +221,17 @@ suite.skip('NotebookService:', function (): void {
assert.strictEqual(notebookService.languageMagics.length, 0, 'No language magics should exist after creation');
assert.strictEqual(notebookService.listNotebookEditors().length, 0, 'No notebook editors should be listed');
assert.strictEqual(notebookService.getMimeRegistry().mimeTypes.length, 15, 'MIME Types need to have appropriate tests when added or removed');
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
assert.deepStrictEqual(notebookService.getProvidersForFileType('.ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
assert.strictEqual(notebookService.getStandardKernelsForProvider('sql').length, 1, 'SQL kernel should be provided by default');
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider'), undefined, 'Other provider should not have kernels since it has not been added as a provider');
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'IPYNB file extension should be supported by default');
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['.ipynb'], 'IPYNB file extension should be supported by default');
await notebookService.registrationComplete;
assert.ok(notebookService.isRegistrationComplete, `notebookService.isRegistrationComplete should be true once its registrationComplete promise is resolved`);
});
test('Validate another provider added successfully', async function (): Promise<void> {
await notebookService.registrationComplete;
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
assert.deepStrictEqual(notebookService.getProvidersForFileType('.ipynb'), ['sql'], 'sql provider should be registered for ipynb extension');
const otherProviderRegistration: ProviderDescriptionRegistration = {
fileExtensions: ['ipynb'],
@@ -246,8 +246,8 @@ suite.skip('NotebookService:', function (): void {
const notebookRegistry = Registry.as<INotebookProviderRegistry>(NotebookProviderRegistryId);
notebookRegistry.registerProviderDescription(otherProviderRegistration);
assert.deepStrictEqual(notebookService.getProvidersForFileType('ipynb'), ['sql', 'otherProvider'], 'otherProvider should also be registered for ipynb extension');
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['IPYNB'], 'Only IPYNB should be registered as supported file extension');
assert.deepStrictEqual(notebookService.getProvidersForFileType('.ipynb'), ['sql', 'otherProvider'], 'otherProvider should also be registered for ipynb extension');
assert.deepStrictEqual(notebookService.getSupportedFileExtensions(), ['.ipynb'], 'Only IPYNB should be registered as supported file extension');
assert.strictEqual(notebookService.getStandardKernelsForProvider('otherProvider').length, 1, 'otherProvider kernel info could not be found');
assert.deepStrictEqual(notebookService.getStandardKernelsForProvider('otherProvider')[0], otherProviderRegistration.standardKernels[0], 'otherProviderRegistration standard kernels does not match');
});