@@ -5,62 +5,66 @@ import { pr } from './fixtures.mts';
55
66const options = { sharedTeamThreshold : 3 } ;
77
8- describe ( 'classifyPullRequests' , ( ) => {
9- it ( 'lists a PR under each requested team' , ( ) => {
10- const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' ] } ) ;
8+ describe ( 'classify' , ( ) => {
9+ describe ( 'classifyPullRequests' , ( ) => {
10+ it ( 'lists a PR under each requested team' , ( ) => {
11+ const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' ] } ) ;
1112
12- const { byTeam } = classifyPullRequests ( [ pullRequest ] , options ) ;
13+ const { byTeam } = classifyPullRequests ( [ pullRequest ] , options ) ;
1314
14- expect ( byTeam ) . toStrictEqual ( { a : [ pullRequest ] , b : [ pullRequest ] } ) ;
15- } ) ;
15+ expect ( byTeam ) . toStrictEqual ( { a : [ pullRequest ] , b : [ pullRequest ] } ) ;
16+ } ) ;
1617
17- it ( 'puts a PR with no team in the fallback' , ( ) => {
18- const pullRequest = pr ( ) ;
18+ it ( 'puts a PR with no team in the fallback' , ( ) => {
19+ const pullRequest = pr ( ) ;
1920
20- const { fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
21+ const { fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
2122
22- expect ( fallback . noTeam ) . toStrictEqual ( [ pullRequest ] ) ;
23- } ) ;
23+ expect ( fallback . noTeam ) . toStrictEqual ( [ pullRequest ] ) ;
24+ } ) ;
2425
25- it ( 'keeps a PR with exactly the threshold under its teams' , ( ) => {
26- const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' , 'c' ] } ) ;
26+ it ( 'keeps a PR with exactly the threshold under its teams' , ( ) => {
27+ const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' , 'c' ] } ) ;
2728
28- const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
29+ const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
2930
30- expect ( Object . keys ( byTeam ) ) . toStrictEqual ( [ 'a' , 'b' , 'c' ] ) ;
31- expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ ] ) ;
32- } ) ;
31+ expect ( Object . keys ( byTeam ) ) . toStrictEqual ( [ 'a' , 'b' , 'c' ] ) ;
32+ expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ ] ) ;
33+ } ) ;
3334
34- it ( 'puts a PR with more teams than the threshold in the fallback' , ( ) => {
35- const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' , 'c' , 'd' ] } ) ;
35+ it ( 'puts a PR with more teams than the threshold in the fallback' , ( ) => {
36+ const pullRequest = pr ( { requestedTeams : [ 'a' , 'b' , 'c' , 'd' ] } ) ;
3637
37- const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
38+ const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , options ) ;
3839
39- expect ( byTeam ) . toStrictEqual ( { } ) ;
40- expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ pullRequest ] ) ;
41- } ) ;
40+ expect ( byTeam ) . toStrictEqual ( { } ) ;
41+ expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ pullRequest ] ) ;
42+ } ) ;
43+
44+ it ( 'only counts the owner teams, ignoring case and repeats' , ( ) => {
45+ const pullRequest = pr ( {
46+ requestedTeams : [ 'a' , 'A' , 'b' , 'x' , 'y' , 'z' ] ,
47+ } ) ;
4248
43- it ( 'only counts the owner teams, ignoring case and repeats' , ( ) => {
44- const pullRequest = pr ( { requestedTeams : [ 'a' , 'A' , 'b' , 'x' , 'y' , 'z' ] } ) ;
49+ const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , {
50+ ...options ,
51+ ownerTeams : [ '@MetaMask/a' , 'b' ] ,
52+ } ) ;
4553
46- const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , {
47- ...options ,
48- ownerTeams : [ '@MetaMask/a' , 'b' ] ,
54+ expect ( Object . keys ( byTeam ) ) . toStrictEqual ( [ 'a' , 'b' ] ) ;
55+ expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ ] ) ;
4956 } ) ;
5057
51- expect ( Object . keys ( byTeam ) ) . toStrictEqual ( [ 'a' , 'b' ] ) ;
52- expect ( fallback . sharedByManyTeams ) . toStrictEqual ( [ ] ) ;
53- } ) ;
58+ it ( 'puts a PR in the fallback when no owner team is left' , ( ) => {
59+ const pullRequest = pr ( { requestedTeams : [ 'ui' ] } ) ;
5460
55- it ( 'puts a PR in the fallback when no owner team is left' , ( ) => {
56- const pullRequest = pr ( { requestedTeams : [ 'ui' ] } ) ;
61+ const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , {
62+ ...options ,
63+ ownerTeams : [ 'extension-platform' ] ,
64+ } ) ;
5765
58- const { byTeam, fallback } = classifyPullRequests ( [ pullRequest ] , {
59- ...options ,
60- ownerTeams : [ 'extension-platform' ] ,
66+ expect ( byTeam ) . toStrictEqual ( { } ) ;
67+ expect ( fallback . noTeam ) . toStrictEqual ( [ pullRequest ] ) ;
6168 } ) ;
62-
63- expect ( byTeam ) . toStrictEqual ( { } ) ;
64- expect ( fallback . noTeam ) . toStrictEqual ( [ pullRequest ] ) ;
6569 } ) ;
6670} ) ;
0 commit comments