Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add tests for RoomList #1877

Merged
merged 6 commits into from
May 4, 2018
Merged

Add tests for RoomList #1877

merged 6 commits into from
May 4, 2018

Conversation

lukebarnard1
Copy link
Contributor

  • Move waitForUpdate (this wasn't necessary in the end)
  • Install lolex for clock mocking (this is what sinon uses under the hood but using the most recent version directly seemed better)
  • Add tests for optimistic updates in moving room tiles (two tests skipped: dragging from people to rooms is glitchy because the optimistic update doesn't work)
  • Add tests for testing that the room list updates when group data is loaded with new rooms added

Added test output:

 RoomList
    when no tags are selected
      does correct optimistic update when dragging from
        ✓ rooms to people (33ms)
        ✓ rooms to favourites (23ms)
        ✓ rooms to low priority (26ms)
        - people to rooms (0ms)
        ... (all others pass)
    when tags are selected
      ✓ displays the correct rooms when the groups rooms are changed (11ms)
      does correct optimistic update when dragging from
        ✓ rooms to people (16ms)
        ✓ rooms to favourites (15ms)
        ✓ rooms to low priority (15ms)
        - people to rooms (0ms)
        ... (all others pass)

Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise lgtm!

import { Room, RoomMember } from 'matrix-js-sdk';

function generateRoomId() {
return '!' + Math.random().toString().slice(2, 10) + ':domain';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a bit moot in this case, but in general for unit tests where nothing is stored between runs, I would probably use the same data each time to make them completely deterministic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRL we discussed and decided that it's ok to do this for room IDs (as here we simulate a homeserver randomly generating unique IDs and the app should be totally ambivalent to the content of the IDs)

@lukebarnard1 lukebarnard1 merged commit aa370b3 into develop May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants