Skip to content

Auth service unit test is incorrect #98

@ghost

Description

How to reproduce:

  • run npm run test
  • all tests succeed as expected
  • modify expects for test on line 62 in auth.service.spec.ts (same issue applies for 73 and 88)
it('should login via hash if token is valid', waitForAsync (() => {
      spyOn(mockService, 'tryLogin');
      spyOn(mockService, 'silentRefresh');
      mockService.updateTokenValidity(true);

      service.runInitialLoginSequence().then(() => {
        expect(mockService.tryLogin).toHaveBeenCalled();
        expect(mockService.silentRefresh).not.toHaveBeenCalled();
      });

to

it('should login via hash if token is valid', waitForAsync (() => {
      spyOn(mockService, 'tryLogin');
      spyOn(mockService, 'silentRefresh');
      mockService.updateTokenValidity(true);

      service.runInitialLoginSequence().then(() => {
        expect(mockService.tryLogin).not.toHaveBeenCalled();
        expect(mockService.silentRefresh).toHaveBeenCalled();
      });
  • run npm run test again
  • test still succeeds which shouldn't happen

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingup-for-grabsGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions