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

window.location.hostname not populated when window.location.href set. #2688

Closed
1 of 3 tasks
cam-narzt opened this issue Oct 1, 2020 · 0 comments · Fixed by #2689
Closed
1 of 3 tasks

window.location.hostname not populated when window.location.href set. #2688

cam-narzt opened this issue Oct 1, 2020 · 0 comments · Fixed by #2689
Labels

Comments

@cam-narzt
Copy link
Contributor

Stencil version:

I'm submitting a:

Current behavior:
In a jest spec unit test test that the window.location.hostname is set when the href is set:

import { newSpecPage } from '@stencil/core/testing';

describe('location.hostname', () => {
  it('has a hostname', async () => {
    const page = await newSpecPage({
      url:'http://test.example.com/',
      components: [],
      html: `<html></html>`,
    });
    expect(window.location.hostname).toEqual('test.example.com');
  });
});

output:

 FAIL  src/components/location-hostname/test/location-hostname.spec.tsx
  ● location-hostname › has a hostname

    expect(received).toEqual(expected) // deep equality

    Expected: "test.example.com"
    Received: ""

       8 |       html: `<html></html>`,
       9 |     });
    > 10 |     expect(window.location.hostname).toEqual('test.example.com');
         |                                      ^
      11 |   });

      at Object.<anonymous> (src/components/location-hostname/test/location-hostname.spec.tsx:10:38)

As we can see the hostname is not set.

Expected behavior:
The hostname should be populated.

Steps to reproduce:
See current behaviour.

Related code:
https://github.com/ionic-team/stencil/blob/master/src/mock-doc/location.ts#L22

Other information:
I have a PR ready to submit to fix this, but the contributing guidelines said to create an issue first.

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

Successfully merging a pull request may close this issue.

1 participant