|
| 1 | +/** |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @format |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +const checkBranchTarget = require('../checkBranchTarget'); |
| 13 | + |
| 14 | +describe('checkBranchTarget', () => { |
| 15 | + test('passes for main', () => { |
| 16 | + expect(checkBranchTarget('main')).toEqual({ |
| 17 | + message: '', |
| 18 | + status: 'PASS', |
| 19 | + shouldAddPickLabel: false, |
| 20 | + }); |
| 21 | + }); |
| 22 | + |
| 23 | + test('passes for a stable branch and adds the pick label', () => { |
| 24 | + expect(checkBranchTarget('0.76-stable')).toEqual({ |
| 25 | + message: '', |
| 26 | + status: 'PASS', |
| 27 | + shouldAddPickLabel: true, |
| 28 | + }); |
| 29 | + }); |
| 30 | + |
| 31 | + test('passes for the head branch of another open PR', () => { |
| 32 | + expect(checkBranchTarget('pr58950', true)).toEqual({ |
| 33 | + message: '', |
| 34 | + status: 'PASS', |
| 35 | + shouldAddPickLabel: false, |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + test('fails for any other branch', () => { |
| 40 | + const {message, status, shouldAddPickLabel} = |
| 41 | + checkBranchTarget('feature-branch'); |
| 42 | + |
| 43 | + expect(status).toBe('FAIL'); |
| 44 | + expect(message).toContain('`feature-branch`'); |
| 45 | + expect(shouldAddPickLabel).toBe(false); |
| 46 | + }); |
| 47 | +}); |
0 commit comments