Skip to content

Commit

Permalink
Fix #4886 and add test. (#4954)
Browse files Browse the repository at this point in the history
  • Loading branch information
NaridaL authored and suchipi committed Aug 8, 2018
1 parent 1391891 commit c83d5b1
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -5814,7 +5814,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(() => {}) }

0 comments on commit c83d5b1

Please sign in to comment.