2017-07-26 15:37:14 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2020-03-02 12:35:30 -05:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2020-03-02 12:35:30 -05:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2020-05-05 16:12:39 -04:00
|
|
|
var assert = require('assert');
|
2017-07-26 15:37:14 -04:00
|
|
|
var extractPaths = require('./json_extract').extractPaths;
|
|
|
|
|
|
|
|
var SAMPLE_LABELS = [
|
|
|
|
{
|
2020-05-05 16:12:39 -04:00
|
|
|
'id': 149476251,
|
|
|
|
'url': 'https://api.github.com/repos/angular/angular/labels/cla:%20yes',
|
|
|
|
'name': 'cla: yes',
|
|
|
|
'color': '009800',
|
|
|
|
'default': false
|
2017-07-26 15:37:14 -04:00
|
|
|
},
|
|
|
|
{
|
2020-05-05 16:12:39 -04:00
|
|
|
'id': 533874619,
|
|
|
|
'url': 'https://api.github.com/repos/angular/angular/labels/comp:%20aio',
|
|
|
|
'name': 'comp: aio',
|
|
|
|
'color': 'c7def8',
|
|
|
|
'default': false
|
2017-07-26 15:37:14 -04:00
|
|
|
},
|
|
|
|
{
|
2020-05-05 16:12:39 -04:00
|
|
|
'id': 133556520,
|
|
|
|
'url': 'https://api.github.com/repos/angular/angular/labels/PR%20action:%20merge',
|
|
|
|
'name': 'PR action: merge',
|
|
|
|
'color': '99ff66',
|
|
|
|
'default': false
|
2017-07-26 15:37:14 -04:00
|
|
|
},
|
|
|
|
{
|
2020-05-05 16:12:39 -04:00
|
|
|
'id': 655699838,
|
|
|
|
'url': 'https://api.github.com/repos/angular/angular/labels/PR%20target:%20master%20&%20patch',
|
|
|
|
'name': 'PR target: master & patch',
|
|
|
|
'color': '5319e7',
|
|
|
|
'default': false
|
2017-07-26 15:37:14 -04:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
assert.deepEqual(extractPaths({head: {label: 'value1'}}, ['head.label']), ['value1']);
|
2020-05-05 16:12:39 -04:00
|
|
|
assert.deepEqual(
|
|
|
|
extractPaths(SAMPLE_LABELS, ['name']),
|
|
|
|
['cla: yes|comp: aio|PR action: merge|PR target: master & patch']);
|
2017-07-26 15:37:14 -04:00
|
|
|
assert.deepEqual(extractPaths(SAMPLE_LABELS, ['name=^PR target:']), ['PR target: master & patch']);
|