Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

1.4 KB
Raw Blame
import "package:flutter_test/flutter_test.dart";
import "package:photos/utils/avatar_util.dart";

void main() {
  test("email identity is normalized and independent of the label", () {
    final before = AvatarIdentity.account(
      label: "Alice",
      email: " [email protected] ",
      userID: 7,
      personID: "person-1",
      currentUserEmail: null,
    );
    final after = AvatarIdentity.account(
      label: "Bob",
      email: "[email protected]",
      userID: null,
      currentUserEmail: null,
    );

    expect(before.key, "email:[email protected]");
    expect(after.key, before.key);
  });

  test("anonymous identity is independent of its display name", () {
    final before = AvatarIdentity.account(
      label: "Alice",
      email: " [email protected] ",
      userID: -1,
      currentUserEmail: null,
    );
    final after = AvatarIdentity.account(
      label: "Bob",
      email: "[email protected]",
      userID: -1,
      currentUserEmail: null,
    );

    expect(before.key, "anonymous:anon-1");
    expect(after.key, before.key);
  });

  test("marks the signed-in account as the current-user role", () {
    final identity = AvatarIdentity.account(
      label: "Alice",
      email: " [email protected] ",
      userID: 7,
      currentUserID: 7,
      currentUserEmail: "[email protected]",
    );

    expect(identity.role, AvatarIdentityRole.currentUser);
  });
}