mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: add Prettier (#5825)
This commit is contained in:
@@ -14,17 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const {runCommands, ensureReleasedAPILinks} = require('.');
|
||||
const { runCommands, ensureReleasedAPILinks } = require('.');
|
||||
const Source = require('../Source');
|
||||
const expect = require('expect');
|
||||
|
||||
describe('doclint preprocessor specs', function() {
|
||||
|
||||
describe('ensureReleasedAPILinks', function() {
|
||||
it('should work with non-release version', function() {
|
||||
const source = new Source('doc.md', `
|
||||
describe('doclint preprocessor specs', function () {
|
||||
describe('ensureReleasedAPILinks', function () {
|
||||
it('should work with non-release version', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
[API](https://github.com/puppeteer/puppeteer/blob/v1.1.0/docs/api.md#class-page)
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = ensureReleasedAPILinks([source], '1.3.0-post');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -33,10 +35,13 @@ describe('doclint preprocessor specs', function() {
|
||||
[API](https://github.com/puppeteer/puppeteer/blob/v1.3.0/docs/api.md#class-page)
|
||||
`);
|
||||
});
|
||||
it('should work with release version', function() {
|
||||
const source = new Source('doc.md', `
|
||||
it('should work with release version', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
[API](https://github.com/puppeteer/puppeteer/blob/v1.1.0/docs/api.md#class-page)
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = ensureReleasedAPILinks([source], '1.3.0');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -45,10 +50,13 @@ describe('doclint preprocessor specs', function() {
|
||||
[API](https://github.com/puppeteer/puppeteer/blob/v1.3.0/docs/api.md#class-page)
|
||||
`);
|
||||
});
|
||||
it('should keep master links intact', function() {
|
||||
const source = new Source('doc.md', `
|
||||
it('should keep master links intact', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
[API](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#class-page)
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = ensureReleasedAPILinks([source], '1.3.0');
|
||||
expect(messages.length).toBe(0);
|
||||
expect(source.text()).toBe(`
|
||||
@@ -57,22 +65,28 @@ describe('doclint preprocessor specs', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('runCommands', function() {
|
||||
it('should throw for unknown command', function() {
|
||||
const source = new Source('doc.md', `
|
||||
describe('runCommands', function () {
|
||||
it('should throw for unknown command', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
<!-- gen:unknown-command -->something<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.1.1');
|
||||
expect(source.hasUpdatedText()).toBe(false);
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('error');
|
||||
expect(messages[0].text).toContain('Unknown command');
|
||||
});
|
||||
describe('gen:version', function() {
|
||||
it('should work', function() {
|
||||
const source = new Source('doc.md', `
|
||||
describe('gen:version', function () {
|
||||
it('should work', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
Puppeteer <!-- gen:version -->XXX<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.2.0');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -81,10 +95,13 @@ describe('doclint preprocessor specs', function() {
|
||||
Puppeteer <!-- gen:version -->v1.2.0<!-- gen:stop -->
|
||||
`);
|
||||
});
|
||||
it('should work for *-post versions', function() {
|
||||
const source = new Source('doc.md', `
|
||||
it('should work for *-post versions', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
Puppeteer <!-- gen:version -->XXX<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.2.0-post');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -93,13 +110,18 @@ describe('doclint preprocessor specs', function() {
|
||||
Puppeteer <!-- gen:version -->Tip-Of-Tree<!-- gen:stop -->
|
||||
`);
|
||||
});
|
||||
it('should tolerate different writing', function() {
|
||||
const source = new Source('doc.md', `Puppeteer v<!-- gEn:version -->WHAT
|
||||
<!-- GEN:stop -->`);
|
||||
it('should tolerate different writing', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`Puppeteer v<!-- gEn:version -->WHAT
|
||||
<!-- GEN:stop -->`
|
||||
);
|
||||
runCommands([source], '1.1.1');
|
||||
expect(source.text()).toBe(`Puppeteer v<!-- gEn:version -->v1.1.1<!-- GEN:stop -->`);
|
||||
expect(source.text()).toBe(
|
||||
`Puppeteer v<!-- gEn:version -->v1.1.1<!-- GEN:stop -->`
|
||||
);
|
||||
});
|
||||
it('should not tolerate missing gen:stop', function() {
|
||||
it('should not tolerate missing gen:stop', function () {
|
||||
const source = new Source('doc.md', `<!--GEN:version-->`);
|
||||
const messages = runCommands([source], '1.2.0');
|
||||
expect(source.hasUpdatedText()).toBe(false);
|
||||
@@ -108,11 +130,14 @@ describe('doclint preprocessor specs', function() {
|
||||
expect(messages[0].text).toContain(`Failed to find 'gen:stop'`);
|
||||
});
|
||||
});
|
||||
describe('gen:empty-if-release', function() {
|
||||
it('should clear text when release version', function() {
|
||||
const source = new Source('doc.md', `
|
||||
describe('gen:empty-if-release', function () {
|
||||
it('should clear text when release version', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
<!-- gen:empty-if-release -->XXX<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.1.1');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -121,10 +146,13 @@ describe('doclint preprocessor specs', function() {
|
||||
<!-- gen:empty-if-release --><!-- gen:stop -->
|
||||
`);
|
||||
});
|
||||
it('should keep text when non-release version', function() {
|
||||
const source = new Source('doc.md', `
|
||||
it('should keep text when non-release version', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
<!-- gen:empty-if-release -->XXX<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.1.1-post');
|
||||
expect(messages.length).toBe(0);
|
||||
expect(source.text()).toBe(`
|
||||
@@ -132,12 +160,15 @@ describe('doclint preprocessor specs', function() {
|
||||
`);
|
||||
});
|
||||
});
|
||||
describe('gen:toc', function() {
|
||||
describe('gen:toc', function () {
|
||||
it('should work', () => {
|
||||
const source = new Source('doc.md', `<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
### class: page
|
||||
#### page.$
|
||||
#### page.$$`);
|
||||
#### page.$$`
|
||||
);
|
||||
const messages = runCommands([source], '1.3.0');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -152,13 +183,16 @@ describe('doclint preprocessor specs', function() {
|
||||
#### page.$$`);
|
||||
});
|
||||
it('should work with code blocks', () => {
|
||||
const source = new Source('doc.md', `<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
### class: page
|
||||
|
||||
\`\`\`bash
|
||||
# yo comment
|
||||
\`\`\`
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.3.0');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -174,9 +208,12 @@ describe('doclint preprocessor specs', function() {
|
||||
`);
|
||||
});
|
||||
it('should work with links in titles', () => {
|
||||
const source = new Source('doc.md', `<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`<!-- gen:toc -->XXX<!-- gen:stop -->
|
||||
### some [link](#foobar) here
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.3.0');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
@@ -188,12 +225,15 @@ describe('doclint preprocessor specs', function() {
|
||||
`);
|
||||
});
|
||||
});
|
||||
it('should work with multiple commands', function() {
|
||||
const source = new Source('doc.md', `
|
||||
it('should work with multiple commands', function () {
|
||||
const source = new Source(
|
||||
'doc.md',
|
||||
`
|
||||
<!-- gen:version -->XXX<!-- gen:stop -->
|
||||
<!-- gen:empty-if-release -->YYY<!-- gen:stop -->
|
||||
<!-- gen:version -->ZZZ<!-- gen:stop -->
|
||||
`);
|
||||
`
|
||||
);
|
||||
const messages = runCommands([source], '1.1.1');
|
||||
expect(messages.length).toBe(1);
|
||||
expect(messages[0].type).toBe('warning');
|
||||
|
||||
Reference in New Issue
Block a user