Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {assert} from 'chai'; |
| 6 | import {computeRoleByProjectName} from './helpers.js'; |
| 7 | |
| 8 | describe('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 | }); |