Skip to content

get the body of a block? #16

@jashmenn

Description

@jashmenn

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions