"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/angular_devkit/core/src/workspace/core_spec.ts" between
angular-cli-12.0.3.tar.gz and angular-cli-12.0.4.tar.gz

About: Angular CLI is a command line interface for Angular.

core_spec.ts  (angular-cli-12.0.3):core_spec.ts  (angular-cli-12.0.4)
skipping to change at line 22 skipping to change at line 22
WorkspaceFormat, WorkspaceFormat,
_test_addWorkspaceFile, _test_addWorkspaceFile,
_test_removeWorkspaceFile, _test_removeWorkspaceFile,
readWorkspace, readWorkspace,
writeWorkspace, writeWorkspace,
} from './core'; } from './core';
import { WorkspaceDefinition } from './definitions'; import { WorkspaceDefinition } from './definitions';
import { WorkspaceHost } from './host'; import { WorkspaceHost } from './host';
describe('readWorkspace', () => { describe('readWorkspace', () => {
it('attempts to read from specified file path [angular.json]', async (done) => { it('attempts to read from specified file path [angular.json]', async () => {
const requestedPath = '/path/to/workspace/angular.json'; const requestedPath = '/path/to/workspace/angular.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).toBe(requestedPath); expect(path).toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile(path) { async isFile(path) {
skipping to change at line 45 skipping to change at line 45
async isDirectory(path) { async isDirectory(path) {
if (path !== requestedPath) { if (path !== requestedPath) {
fail(); fail();
} }
return false; return false;
}, },
}; };
await readWorkspace(requestedPath, host); await readWorkspace(requestedPath, host);
done();
}); });
it('attempts to read from specified file path [.angular.json]', async (done) = > { it('attempts to read from specified file path [.angular.json]', async () => {
const requestedPath = '/path/to/workspace/.angular.json'; const requestedPath = '/path/to/workspace/.angular.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).toBe(requestedPath); expect(path).toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile(path) { async isFile(path) {
skipping to change at line 72 skipping to change at line 70
async isDirectory(path) { async isDirectory(path) {
if (path !== requestedPath) { if (path !== requestedPath) {
fail(); fail();
} }
return false; return false;
}, },
}; };
await readWorkspace(requestedPath, host); await readWorkspace(requestedPath, host);
done();
}); });
it('attempts to read from specified non-standard file path with format', async (done) => { it('attempts to read from specified non-standard file path with format', async () => {
const requestedPath = '/path/to/workspace/abc.json'; const requestedPath = '/path/to/workspace/abc.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).toBe(requestedPath); expect(path).toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile(path) { async isFile(path) {
skipping to change at line 99 skipping to change at line 95
async isDirectory(path) { async isDirectory(path) {
if (path !== requestedPath) { if (path !== requestedPath) {
fail(); fail();
} }
return false; return false;
}, },
}; };
await readWorkspace(requestedPath, host, WorkspaceFormat.JSON); await readWorkspace(requestedPath, host, WorkspaceFormat.JSON);
done();
}); });
it('errors when reading from specified non-standard file path without format', async (done) => { it('errors when reading from specified non-standard file path without format', async () => {
const requestedPath = '/path/to/workspace/abc.json'; const requestedPath = '/path/to/workspace/abc.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).toBe(requestedPath); expect(path).toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile(path) { async isFile(path) {
skipping to change at line 131 skipping to change at line 125
return false; return false;
}, },
}; };
try { try {
await readWorkspace(requestedPath, host); await readWorkspace(requestedPath, host);
fail(); fail();
} catch (e) { } catch (e) {
expect(e.message).toContain('Unable to determine format for workspace path '); expect(e.message).toContain('Unable to determine format for workspace path ');
} }
done();
}); });
it('errors when reading from specified file path with invalid specified format ', async (done) => { it('errors when reading from specified file path with invalid specified format ', async () => {
const requestedPath = '/path/to/workspace/angular.json'; const requestedPath = '/path/to/workspace/angular.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).toBe(requestedPath); expect(path).toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile(path) { async isFile(path) {
skipping to change at line 163 skipping to change at line 155
return false; return false;
}, },
}; };
try { try {
await readWorkspace(requestedPath, host, 12 as WorkspaceFormat); await readWorkspace(requestedPath, host, 12 as WorkspaceFormat);
fail(); fail();
} catch (e) { } catch (e) {
expect(e.message).toContain('Unsupported workspace format'); expect(e.message).toContain('Unsupported workspace format');
} }
done();
}); });
it('attempts to find/read from directory path', async (done) => { it('attempts to find/read from directory path', async () => {
const requestedPath = getSystemPath(normalize('/path/to/workspace')); const requestedPath = getSystemPath(normalize('/path/to/workspace'));
const expectedFile = getSystemPath(join(normalize(requestedPath), '.angular. json')); const expectedFile = getSystemPath(join(normalize(requestedPath), '.angular. json'));
const isFileChecks: string[] = []; const isFileChecks: string[] = [];
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).not.toBe(requestedPath); expect(path).not.toBe(requestedPath);
expect(path).toBe(expectedFile); expect(path).toBe(expectedFile);
return '{ "version": 1 }'; return '{ "version": 1 }';
skipping to change at line 204 skipping to change at line 194
}; };
await readWorkspace(requestedPath, host); await readWorkspace(requestedPath, host);
isFileChecks.sort(); isFileChecks.sort();
expect(isFileChecks).toEqual( expect(isFileChecks).toEqual(
[ [
getSystemPath(join(normalize(requestedPath), 'angular.json')), getSystemPath(join(normalize(requestedPath), 'angular.json')),
getSystemPath(join(normalize(requestedPath), '.angular.json')), getSystemPath(join(normalize(requestedPath), '.angular.json')),
].sort(), ].sort(),
); );
done();
}); });
it('attempts to find/read only files for specified format from directory path' , async (done) => { it('attempts to find/read only files for specified format from directory path' , async () => {
const requestedPath = '/path/to/workspace'; const requestedPath = '/path/to/workspace';
const isFileChecks: string[] = []; const isFileChecks: string[] = [];
const readFileChecks: string[] = []; const readFileChecks: string[] = [];
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).not.toBe(requestedPath); expect(path).not.toBe(requestedPath);
readFileChecks.push(path); readFileChecks.push(path);
return '{ "version": 1 }'; return '{ "version": 1 }';
skipping to change at line 249 skipping to change at line 237
await readWorkspace(requestedPath, host, WorkspaceFormat.JSON); await readWorkspace(requestedPath, host, WorkspaceFormat.JSON);
} finally { } finally {
_test_removeWorkspaceFile('wrong.format'); _test_removeWorkspaceFile('wrong.format');
} }
isFileChecks.sort(); isFileChecks.sort();
expect(isFileChecks).toEqual([getSystemPath(join(normalize(requestedPath), ' angular.json'))]); expect(isFileChecks).toEqual([getSystemPath(join(normalize(requestedPath), ' angular.json'))]);
readFileChecks.sort(); readFileChecks.sort();
expect(readFileChecks).toEqual([getSystemPath(join(normalize(requestedPath), 'angular.json'))]); expect(readFileChecks).toEqual([getSystemPath(join(normalize(requestedPath), 'angular.json'))]);
done();
}); });
it('errors when no file found from specified directory path', async (done) => { it('errors when no file found from specified directory path', async () => {
const requestedPath = '/path/to/workspace'; const requestedPath = '/path/to/workspace';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile(path) { async readFile(path) {
expect(path).not.toBe(requestedPath); expect(path).not.toBe(requestedPath);
return '{ "version": 1 }'; return '{ "version": 1 }';
}, },
async writeFile() {}, async writeFile() {},
async isFile() { async isFile() {
skipping to change at line 283 skipping to change at line 269
return false; return false;
}, },
}; };
try { try {
await readWorkspace(requestedPath, host); await readWorkspace(requestedPath, host);
fail(); fail();
} catch (e) { } catch (e) {
expect(e.message).toContain('Unable to locate a workspace file'); expect(e.message).toContain('Unable to locate a workspace file');
} }
done();
}); });
}); });
describe('writeWorkspace', () => { describe('writeWorkspace', () => {
it('attempts to write to specified file path', async (done) => { it('attempts to write to specified file path', async () => {
const requestedPath = '/path/to/workspace/angular.json'; const requestedPath = '/path/to/workspace/angular.json';
let writtenPath: string | undefined; let writtenPath: string | undefined;
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile() { async readFile() {
fail(); fail();
return ''; return '';
}, },
async writeFile(path) { async writeFile(path) {
skipping to change at line 317 skipping to change at line 301
}, },
async isDirectory() { async isDirectory() {
fail(); fail();
return false; return false;
}, },
}; };
await writeWorkspace({} as WorkspaceDefinition, host, requestedPath, Workspa ceFormat.JSON); await writeWorkspace({} as WorkspaceDefinition, host, requestedPath, Workspa ceFormat.JSON);
expect(writtenPath).toBe(requestedPath); expect(writtenPath).toBe(requestedPath);
done();
}); });
it('errors when writing to specified file path with invalid specified format', async (done) => { it('errors when writing to specified file path with invalid specified format', async () => {
const requestedPath = '/path/to/workspace/angular.json'; const requestedPath = '/path/to/workspace/angular.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile() { async readFile() {
fail(); fail();
return ''; return '';
}, },
async writeFile() { async writeFile() {
fail(); fail();
skipping to change at line 351 skipping to change at line 333
return false; return false;
}, },
}; };
try { try {
await writeWorkspace({} as WorkspaceDefinition, host, requestedPath, 12 as WorkspaceFormat); await writeWorkspace({} as WorkspaceDefinition, host, requestedPath, 12 as WorkspaceFormat);
fail(); fail();
} catch (e) { } catch (e) {
expect(e.message).toContain('Unsupported workspace format'); expect(e.message).toContain('Unsupported workspace format');
} }
done();
}); });
it('errors when writing custom workspace without specified format', async (don e) => { it('errors when writing custom workspace without specified format', async () = > {
const requestedPath = '/path/to/workspace/angular.json'; const requestedPath = '/path/to/workspace/angular.json';
const host: WorkspaceHost = { const host: WorkspaceHost = {
async readFile() { async readFile() {
fail(); fail();
return ''; return '';
}, },
async writeFile() { async writeFile() {
fail(); fail();
skipping to change at line 385 skipping to change at line 365
return false; return false;
}, },
}; };
try { try {
await writeWorkspace({} as WorkspaceDefinition, host, requestedPath); await writeWorkspace({} as WorkspaceDefinition, host, requestedPath);
fail(); fail();
} catch (e) { } catch (e) {
expect(e.message).toContain('A format is required'); expect(e.message).toContain('A format is required');
} }
done();
}); });
}); });
 End of changes. 22 change blocks. 
33 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)