blob: f8e5c518f49b3e13ebdd7ff84b65f5ec74322cc8 [file] [log] [blame]
/**
* @license
* Copyright 2021 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
import './test/test-setup';
import {getTrailer} from './common';
suite('common-test', () => {
test('getTrailer', () => {
const commitMsg =
'Commit message\n' + 'Trailer-1: foo\n' + 'Trailer-2: bar\n';
const trailer = getTrailer(commitMsg, 'Trailer');
assert.equal(trailer, '');
const trailer1 = getTrailer(commitMsg, 'Trailer-1');
assert.equal(trailer1, 'Trailer-1: foo\n');
const trailer2 = getTrailer(commitMsg, 'Trailer-2');
assert.equal(trailer2, 'Trailer-2: bar\n');
});
test('getTrailer CAPS= style tags', () => {
const commitMsg =
'Commit message\n' + 'OLD_STYLE=foo\n' + 'OLD_STYLE=bar\n';
const trailer = getTrailer(commitMsg, 'Old-Style');
assert.equal(trailer, 'Old-Style: foo\nOld-Style: bar\n');
});
test('getTrailer trailer with comma', () => {
const commitMsg =
'Commit message\n' +
'Cq-Include-Trybots: chrome/try:win-chrome,mac-chrome';
const trailer = getTrailer(commitMsg, 'Cq-Include-Trybots');
assert.equal(
trailer,
'Cq-Include-Trybots: chrome/try:win-chrome,mac-chrome\n'
);
});
test('getTrailer repeated trailers', () => {
const commitMsg = 'Commit message\n' + 'Trailer: a,b\n' + 'Trailer: c\n';
const trailer = getTrailer(commitMsg, 'Trailer');
assert.equal(trailer, 'Trailer: a,b\nTrailer: c\n');
});
});