Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format angular jasmine it("should ...", fakeAsync(() => { ... correctly. #4954

Merged
merged 1 commit into from Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -5816,7 +5816,9 @@ function isAngularTestWrapper(node) {
(node.type === "CallExpression" ||
node.type === "OptionalCallExpression") &&
node.callee.type === "Identifier" &&
(node.callee.name === "async" || node.callee.name === "inject")
(node.callee.name === "async" ||
node.callee.name === "inject" ||
node.callee.name === "fakeAsync")
);
}

Expand Down
102 changes: 102 additions & 0 deletions tests/test_declarations/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -102,6 +102,108 @@ function x() {

`;

exports[`angular_fakeAsync.js - flow-verify 1`] = `
beforeEach(fakeAsync(() => {
// code
}));

afterAll(fakeAsync(() => {
console.log('Hello');
}));

it('should create the app', fakeAsync(() => {
//code
}));

it("does something really long and complicated so I have to write a very long name for the test", fakeAsync(() => {
// code
}));

/*
* isTestCall(parent) should only be called when parent exists
* and parent.type is CallExpression. This test makes sure that
* no errors are thrown when calling isTestCall(parent)
*/
function x() { fakeAsync(() => {}) }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beforeEach(fakeAsync(() => {
// code
}));

afterAll(fakeAsync(() => {
console.log("Hello");
}));

it("should create the app", fakeAsync(() => {
//code
}));

it("does something really long and complicated so I have to write a very long name for the test", fakeAsync(() => {
// code
}));

/*
* isTestCall(parent) should only be called when parent exists
* and parent.type is CallExpression. This test makes sure that
* no errors are thrown when calling isTestCall(parent)
*/
function x() {
fakeAsync(() => {});
}

`;

exports[`angular_fakeAsync.js - flow-verify 2`] = `
beforeEach(fakeAsync(() => {
// code
}));

afterAll(fakeAsync(() => {
console.log('Hello');
}));

it('should create the app', fakeAsync(() => {
//code
}));

it("does something really long and complicated so I have to write a very long name for the test", fakeAsync(() => {
// code
}));

/*
* isTestCall(parent) should only be called when parent exists
* and parent.type is CallExpression. This test makes sure that
* no errors are thrown when calling isTestCall(parent)
*/
function x() { fakeAsync(() => {}) }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
beforeEach(fakeAsync(() => {
// code
}));

afterAll(fakeAsync(() => {
console.log("Hello");
}));

it("should create the app", fakeAsync(() => {
//code
}));

it("does something really long and complicated so I have to write a very long name for the test", fakeAsync(() => {
// code
}));

/*
* isTestCall(parent) should only be called when parent exists
* and parent.type is CallExpression. This test makes sure that
* no errors are thrown when calling isTestCall(parent)
*/
function x() {
fakeAsync(() => {});
}

`;

exports[`angularjs_inject.js - flow-verify 1`] = `
beforeEach(inject(($fooService, $barService) => {
// code
Expand Down
22 changes: 22 additions & 0 deletions tests/test_declarations/angular_fakeAsync.js
@@ -0,0 +1,22 @@
beforeEach(fakeAsync(() => {
// code
}));

afterAll(fakeAsync(() => {
console.log('Hello');
}));

it('should create the app', fakeAsync(() => {
//code
}));

it("does something really long and complicated so I have to write a very long name for the test", fakeAsync(() => {
// code
}));

/*
* isTestCall(parent) should only be called when parent exists
* and parent.type is CallExpression. This test makes sure that
* no errors are thrown when calling isTestCall(parent)
*/
function x() { fakeAsync(() => {}) }