All the docs related files (docs-app, doc-gen, content, etc) are now to be found inside the `/aio` folder. The related gulp tasks have been moved from the top level gulp file to a new one inside the `/aio` folder. The structure of the `/aio` folder now looks like: ``` /aio/ build/ # gulp tasks content/ #MARKDOWN FILES for devguides, cheatsheet, etc devguides/ cheatsheets/ transforms/ #dgeni packages, templates, etc src/ app/ assets/ content/ #HTML + JSON build artifacts produced by dgeni from /aio/content. #This dir is .gitignored-ed e2e/ #protractor tests for the doc viewer app node_modules/ #dependencies for both the doc viewer builds and the dgeni stuff #This dir is .gitignored-ed gulpfile.js #Tasks for generating docs and building & deploying the doc viewer ``` Closes #14361
75 lines
3.1 KiB
JavaScript
75 lines
3.1 KiB
JavaScript
var testPackage = require('../../helpers/test-package');
|
|
var Dgeni = require('dgeni');
|
|
|
|
describe('cheatsheetItemParser', function() {
|
|
var dgeni, injector, cheatsheetItemParser;
|
|
|
|
beforeEach(function() {
|
|
dgeni = new Dgeni([testPackage('cheatsheet-package')]);
|
|
injector = dgeni.configureInjector();
|
|
cheatsheetItemParser = injector.get('cheatsheetItemParser');
|
|
var targetEnvironments = injector.get('targetEnvironments');
|
|
targetEnvironments.addAllowed('js');
|
|
targetEnvironments.addAllowed('ts', true);
|
|
});
|
|
|
|
describe('no language targets', function() {
|
|
it('should extract the syntax', function() {
|
|
expect(cheatsheetItemParser('syntax:\n`abc`'))
|
|
.toEqual({syntax: 'abc', bold: [], description: ''});
|
|
});
|
|
|
|
it('should extract the bolds', function() {
|
|
expect(cheatsheetItemParser('syntax:\n`abc`|`bold1`|`bold2`'))
|
|
.toEqual({syntax: 'abc', bold: ['bold1', 'bold2'], description: ''});
|
|
});
|
|
|
|
it('should extract the description', function() {
|
|
expect(cheatsheetItemParser('syntax:\n`abc`|`bold1`|`bold2`\ndescription:\nsome description'))
|
|
.toEqual({syntax: 'abc', bold: ['bold1', 'bold2'], description: 'some description'});
|
|
});
|
|
|
|
it('should allow bold to be optional', function() {
|
|
expect(cheatsheetItemParser('syntax:\n`abc`\ndescription:\nsome description'))
|
|
.toEqual({syntax: 'abc', bold: [], description: 'some description'});
|
|
});
|
|
|
|
it('should allow whitespace between the parts', function() {
|
|
expect(cheatsheetItemParser(
|
|
'syntax:\n`abc`| `bold1`| `bold2`\ndescription:\n\nsome description'))
|
|
.toEqual({syntax: 'abc', bold: ['bold1', 'bold2'], description: 'some description'});
|
|
});
|
|
});
|
|
|
|
describe('with language targets', function() {
|
|
it('should extract the active language', function() {
|
|
expect(cheatsheetItemParser(
|
|
'syntax(ts):\n`abc`|`bold1`|`bold2`\ndescription(ts):\nsome description'))
|
|
.toEqual({syntax: 'abc', bold: ['bold1', 'bold2'], description: 'some description'});
|
|
});
|
|
|
|
it('should ignore the non-active language', function() {
|
|
expect(cheatsheetItemParser(
|
|
'syntax(js):\n`abc`|`bold1`|`bold2`\ndescription(js):\nsome description'))
|
|
.toEqual({syntax: '', bold: [], description: ''});
|
|
});
|
|
|
|
it('should select the active language and ignore non-active language', function() {
|
|
expect(cheatsheetItemParser(
|
|
'syntax(js):\n`JS`|`boldJS``\n' +
|
|
'syntax(ts):\n`TS`|`boldTS`\n' +
|
|
'description(js):\nJS description\n' +
|
|
'description(ts):\nTS description'))
|
|
.toEqual({syntax: 'TS', bold: ['boldTS'], description: 'TS description'});
|
|
});
|
|
|
|
it('should error if a language target is used that is not allowed', function() {
|
|
expect(function() {
|
|
cheatsheetItemParser(
|
|
'syntax(dart):\n`abc`|`bold1`|`bold2`\ndescription(ts):\nsome description');
|
|
})
|
|
.toThrowError(
|
|
'Error accessing target "dart". It is not in the list of allowed targets: js,ts');
|
|
});
|
|
});
|
|
}); |