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

get the body of a block? #16

Open
jashmenn opened this issue Jun 30, 2016 · 1 comment
Open

get the body of a block? #16

jashmenn opened this issue Jun 30, 2016 · 1 comment

Comments

@jashmenn
Copy link
Member

Say we had the following TypeScript:

  describe('initialization', () => {
    it('retrieves the artist', fakeAsync(
      inject([Router, SpotifyService, TestComponentBuilder],
             (router: Router,
              mockSpotifyService: MockSpotifyService,
              tcb: TestComponentBuilder) => {
        const fixture = tcb.createFakeAsync(RootCmp);
        advance(fixture);

        router.navigateByUrl('/artists/2');
        advance(fixture);

        expect(mockSpotifyService.getArtistSpy).toHaveBeenCalledWith('2');
      })));
  });

It would be nice to be able to easily select the interior arrow function.

screenshot 2016-06-30 09 38 27

A few things that might make this easy to do:

  1. A way to select the body (Block) of an element
  2. A way to select the individual arguments of a call
  3. Seems easy and general enough to make a body operation.
  4. Feels a bit tricky. We could do something like get(selection, n), which would give the nth element of selection. But it would be nice if it was generous in it's interpretation of the "listness" of the selection. E.g. if it's an array, the nth element but if it's a function it's the nth parameter. I'm not sure about this.

While we're at it, it would be nice to support getting the value of an object this way as well. E.g. if n was a string, and selection was an object, then you get the value of key n.

@fcoury
Copy link

fcoury commented Jul 26, 2016

Here's another case that seems related. I expected this snippet:

{lang=javascript,crop-query=.cliSystemConfigPackages-.barrels.forEach}
<<[code/first_app/angular2_reddit_base/src/system-config.ts](code/first_app/angular2_reddit_base/src/system-config.ts)

When executed against this code:

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
  cliSystemConfigPackages[barrelName] = { main: 'index' };
});

Gives this output:

When this is the output I expected to get:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants