-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): split disablePrivateOrInternalSupport
- Loading branch information
1 parent
8e09808
commit 9e4222e
Showing
11 changed files
with
290 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
import * as chai from 'chai'; | ||
import {temporaryDir, shell, pkg, exists, exec, read, shellAsync} from '../helpers'; | ||
const expect = chai.expect, | ||
tmp = temporaryDir(), | ||
tsconfigPath = require.resolve('../../../tsconfig.json'), | ||
env = Object.freeze({TS_NODE_PROJECT: tsconfigPath, MODE:'TESTING'}); | ||
|
||
describe('CLI disable flags', () => { | ||
|
||
describe('disabling excluding methods with --disablePrivate', () => { | ||
|
||
let componentFile; | ||
before(function (done) { | ||
tmp.create(); | ||
let ls = shell('node', [ | ||
'../bin/index-cli.js', | ||
'-p', '../test/src/sample-files/tsconfig.simple.json', | ||
'--disablePrivate', | ||
'-d', '../' + tmp.name + '/'], { cwd: tmp.name, env}); | ||
|
||
if (ls.stderr.toString() !== '') { | ||
console.error(`shell error: ${ls.stderr.toString()}`); | ||
done('error'); | ||
} | ||
componentFile = read(`${tmp.name}/components/BarComponent.html`); | ||
done(); | ||
}); | ||
after(() => tmp.clean()); | ||
|
||
it('should exclude methods marked as private', () => { | ||
expect(componentFile).not.to.contain('<code>privateMethod'); | ||
}); | ||
|
||
it('should include methods marked as internal', () => { | ||
expect(componentFile).to.contain('<code>internalMethod'); | ||
}); | ||
|
||
it('should include stuff marked as protected', () => { | ||
expect(componentFile).to.contain('<code>varprotected'); | ||
}); | ||
|
||
it('should display lifecyle hooks', () => { | ||
expect(componentFile).to.contain('<code>ngOnInit'); | ||
}); | ||
}); | ||
|
||
describe('disabling excluding methods with --disableProtected', () => { | ||
|
||
let componentFile; | ||
before(function (done) { | ||
tmp.create(); | ||
let ls = shell('node', [ | ||
'../bin/index-cli.js', | ||
'-p', '../test/src/sample-files/tsconfig.simple.json', | ||
'--disableProtected', | ||
'-d', '../' + tmp.name + '/'], { cwd: tmp.name, env}); | ||
|
||
if (ls.stderr.toString() !== '') { | ||
console.error(`shell error: ${ls.stderr.toString()}`); | ||
done('error'); | ||
} | ||
componentFile = read(`${tmp.name}/components/BarComponent.html`); | ||
done(); | ||
}); | ||
after(() => tmp.clean()); | ||
|
||
it('should exclude methods marked as protected', () => { | ||
expect(componentFile).not.to.contain('<code>varprotected'); | ||
}); | ||
|
||
it('should include methods marked as private', () => { | ||
expect(componentFile).to.contain('<code>privateMethod'); | ||
}); | ||
|
||
it('should include methods marked as internal', () => { | ||
expect(componentFile).to.contain('<code>internalMethod'); | ||
}); | ||
|
||
it('should display lifecyle hooks', () => { | ||
expect(componentFile).to.contain('<code>ngOnInit'); | ||
}); | ||
}); | ||
|
||
describe('disabling excluding methods with --disableInternal', () => { | ||
|
||
let componentFile; | ||
before(function (done) { | ||
tmp.create(); | ||
let ls = shell('node', [ | ||
'../bin/index-cli.js', | ||
'-p', '../test/src/sample-files/tsconfig.simple.json', | ||
'--disableInternal', | ||
'-d', '../' + tmp.name + '/'], { cwd: tmp.name, env}); | ||
|
||
if (ls.stderr.toString() !== '') { | ||
console.error(`shell error: ${ls.stderr.toString()}`); | ||
done('error'); | ||
} | ||
componentFile = read(`${tmp.name}/components/BarComponent.html`); | ||
done(); | ||
}); | ||
after(() => tmp.clean()); | ||
|
||
it('should exclude methods marked as @internal', () => { | ||
expect(componentFile).not.to.contain('<code>internalMethod'); | ||
}); | ||
|
||
it('should include methods marked as private', () => { | ||
expect(componentFile).to.contain('<code>privateMethod'); | ||
}); | ||
|
||
it('should include stuff marked as protected', () => { | ||
expect(componentFile).to.contain('<code>varprotected'); | ||
}); | ||
|
||
it('should display lifecyle hooks', () => { | ||
expect(componentFile).to.contain('<code>ngOnInit'); | ||
}); | ||
}); | ||
|
||
describe('disabling excluding methods with --disableLifeCycleHooks', () => { | ||
|
||
let componentFile; | ||
before(function (done) { | ||
tmp.create(); | ||
let ls = shell('node', [ | ||
'../bin/index-cli.js', | ||
'-p', '../test/src/sample-files/tsconfig.simple.json', | ||
'--disableLifeCycleHooks', | ||
'-d', '../' + tmp.name + '/'], { cwd: tmp.name, env}); | ||
|
||
if (ls.stderr.toString() !== '') { | ||
console.error(`shell error: ${ls.stderr.toString()}`); | ||
done('error'); | ||
} | ||
componentFile = read(`${tmp.name}/components/BarComponent.html`); | ||
done(); | ||
}); | ||
after(() => tmp.clean()); | ||
|
||
it('should exclude lifecyle hooks', () => { | ||
expect(componentFile).not.to.contain('<code>ngOnInit'); | ||
}); | ||
|
||
it('should include methods marked as private', () => { | ||
expect(componentFile).to.contain('<code>privateMethod'); | ||
}); | ||
|
||
it('should include stuff marked as protected', () => { | ||
expect(componentFile).to.contain('<code>varprotected'); | ||
}); | ||
|
||
it('should include methods marked as internal', () => { | ||
expect(componentFile).to.contain('<code>internalMethod'); | ||
}); | ||
}); | ||
|
||
describe('disabling excluding methods with --disableLifeCycleHooks --disableInternal --disableProtected --disablePrivate', () => { | ||
|
||
let componentFile; | ||
before(function (done) { | ||
tmp.create(); | ||
let ls = shell('node', [ | ||
'../bin/index-cli.js', | ||
'-p', '../test/src/sample-files/tsconfig.simple.json', | ||
'--disablePrivate', | ||
'--disableProtected', | ||
'--disableInternal', | ||
'--disableLifeCycleHooks', | ||
'-d', '../' + tmp.name + '/'], { cwd: tmp.name, env}); | ||
|
||
if (ls.stderr.toString() !== '') { | ||
console.error(`shell error: ${ls.stderr.toString()}`); | ||
done('error'); | ||
} | ||
componentFile = read(`${tmp.name}/components/BarComponent.html`); | ||
done(); | ||
}); | ||
after(() => tmp.clean()); | ||
|
||
it('should exclude lifecyle hooks', () => { | ||
expect(componentFile).not.to.contain('<code>ngOnInit'); | ||
}); | ||
|
||
it('should exclude methods marked as private', () => { | ||
expect(componentFile).not.to.contain('<code>privateMethod'); | ||
}); | ||
|
||
it('should exclude stuff marked as protected', () => { | ||
expect(componentFile).not.to.contain('<code>varprotected'); | ||
}); | ||
|
||
it('should exclude methods marked as internal', () => { | ||
expect(componentFile).not.to.contain('<code>internalMethod'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.