angular-cn/aio/transforms/examples-package/services/region-matchers/block-c.spec.js

55 lines
1.7 KiB
JavaScript
Raw Normal View History

const matcher = require('./block-c');
describe('block-c region-matcher', () => {
it('should match start annotations', () => {
let matches;
matches = matcher.regionStartMatcher.exec('/* #docregion A b c */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c ');
matches = matcher.regionStartMatcher.exec('/*#docregion A b c*/');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c');
matches = matcher.regionStartMatcher.exec('/* #docregion */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('');
});
it('should match end annotations', () => {
let matches;
matches = matcher.regionEndMatcher.exec('/* #enddocregion A b c */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c ');
matches = matcher.regionEndMatcher.exec('/*#enddocregion A b c*/');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c');
matches = matcher.regionEndMatcher.exec('/* #enddocregion */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('');
});
it('should match plaster annotations', () => {
let matches;
matches = matcher.plasterMatcher.exec('/* #docplaster A b c */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c ');
matches = matcher.plasterMatcher.exec('/*#docplaster A b c*/');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('A b c');
matches = matcher.plasterMatcher.exec('/* #docplaster */');
expect(matches).not.toBeNull();
expect(matches[1]).toEqual('');
});
it('should create a plaster comment', () => {
expect(matcher.createPlasterComment('... elided ...')).toEqual('/* ... elided ... */');
});
});