blob: 9e3c5a2031864d359ed28f3cd8480cbfc355f19d [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6import {computeRoleByProjectName} from './helpers.js';
7
8describe('computeRoleByProjectName', () => {
9 it('handles empty project memberships', () => {
10 assert.deepEqual(computeRoleByProjectName(undefined), {});
11 assert.deepEqual(computeRoleByProjectName([]), {});
12 });
13
14 it('creates mapping', () => {
15 const projectMembers = [
16 {role: 'OWNER', name: 'projects/project-name/members/1234'},
17 {role: 'COMMITTER', name: 'projects/test/members/1234'},
18 ];
19 assert.deepEqual(computeRoleByProjectName(projectMembers), {
20 'projects/project-name': 'Owner',
21 'projects/test': 'Committer',
22 });
23 });
24});