blob: 56184d324da2ae7c3e062fb35365210189804b3e [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2020 The Chromium Authors
Copybara854996b2021-09-07 19:36:02 +00002// 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});