Example #1
0
    test("limit counted climbers per team per category", ()=>{
      let tt = TH.Factory.createTeamType({_id: 'tt1'});
      let team1 = TH.Factory.createTeam({_id: 'team1'});
      let team2 = TH.Factory.createTeam({_id: 'team2'});
      let cat1 = TH.Factory.createCategory({_id: 'cat1'});
      let cat2 = TH.Factory.createCategory({_id: 'cat2'});
      let event = TH.Factory.createEvent({
        teamType_ids: [tt._id],
        heats: {cat1: cat1.heatFormat, cat2: cat2.heatFormat}});
      let competitors = TH.Factory.createList(
        4, 'createCompetitor',
        (index, options)=>{options.team_ids = ['team1']});
      let other = TH.Factory.createCompetitor({team_ids: ['team2']});

      TH.Factory.createList(4, 'createResult', (index, options)=>{
        options.competitor_id = competitors[index]._id;
        options.scores = [0.1, 100*index];
        options.category_id = 'cat1';
      });

      TH.Factory.createResult({
        competitor_id: other._id, category_id: 'cat1', scores: [0.1, 1000]});
      TH.Factory.createResult({
        competitor_id: competitors[0]._id, category_id: 'cat2', scores: [0.1, 1000]});
      TH.Factory.createResult({
        competitor_id: competitors[1]._id, category_id: 'cat2', scores: [0.1, 1000]});

      event.maxTeamEnties = 3;
      assert.equals(sut.getTeamScores(event), {tt1: {team1: 380, team2: 100}});
      event.maxTeamEnties = 1;
      assert.equals(sut.getTeamScores(event), {tt1: {team1: 170, team2: 100}});
    });
Example #2
0
    test("Team score simple", ()=>{
      let tt1 = TH.Factory.createTeamType({_id: 'tt1'});
      let team1 = TH.Factory.createTeam({_id: 'team1'});
      let team2 = TH.Factory.createTeam({_id: 'team2'});
      let tt2 = TH.Factory.createTeamType({_id: 'tt2'});
      let team3 = TH.Factory.createTeam({_id: 'team3'});
      let cat1 = TH.Factory.createCategory({_id: 'cat1'});
      let cat2 = TH.Factory.createCategory({_id: 'cat2'});

      let event = TH.Factory.createEvent({
        teamType_ids: [tt1._id, tt2._id],
        heats: {cat1: cat1.heatFormat, cat2: cat2.heatFormat},
      });
      let compet1 = TH.Factory.createCompetitor({
        team_ids: [team1._id, team3._id], category_ids: [cat1._id, cat2._id]});
      let compet2 = TH.Factory.createCompetitor({
        team_ids: [team2._id], category_ids: [cat1._id]});
      let compet3 = TH.Factory.createCompetitor({
        team_ids: [team1._id, team3._id]});
      let compet4 = TH.Factory.createCompetitor({
        team_ids: null});

      TH.Factory.createResult({competitor_id: compet1._id, category_id: cat1._id,
                               scores: [0.1, 100]});
      TH.Factory.createResult({competitor_id: compet1._id, category_id: cat2._id,
                               scores: [0.2, 100]});
      TH.Factory.createResult({competitor_id: compet2._id, category_id: cat2._id,
                               scores: [0.5, 500]});
      TH.Factory.createResult({competitor_id: compet3._id, category_id: cat1._id,
                               scores: [0.7, 500]});
      TH.Factory.createResult({competitor_id: compet4._id, category_id: cat1._id,
                               scores: [0.3, 700]});

      assert.equals(sut.getTeamScores(event), {tt1: {team1: 225, team2: 100}, tt2: {team3: 225}});
    });
      test("remove in use with team", ()=>{
        const teamType = TH.Factory.createTeamType();
        TH.Factory.createTeam();

        assert.accessDenied(()=>{
          teamType.authorize(user._id, {remove: true});
        });

      });
Example #4
0
    test("not started", ()=>{
      let tt = TH.Factory.createTeamType({_id: 'tt1'});
      let team = TH.Factory.createTeam({_id: 'team1'});
      let cat = TH.Factory.createCategory({_id: 'cat'});
      let event = TH.Factory.createEvent({_id: 'ev1', teamType_ids: [tt._id],
                                          heats: {cat: 'F1'}});
      let competitors = TH.Factory.createCompetitor({
        _id: 'comp1', team_ids: ['team1'], category_ids: ['cat']});
      let res1 = TH.Factory.createResult({_id: 'res1', scores: [0.1]});
      let res2 = TH.Factory.createResult({_id: 'res2', scores: [0.2]});

      assert.equals(sut.getTeamScores(event), {});
    });
    beforeEach(()=>{
      v.org =TH.Factory.createOrg();
      v.user = TH.Factory.createUser({role: User.ROLE.admin});
      v.event = TH.Factory.createEvent({heats: undefined});
      v.clubType = TH.Factory.createTeamType({name: 'Club'});
      v.team = TH.Factory.createTeam({name: 'Rock Hoppers'});
      v.fjl = TH.Factory.createCategory({
        shortName: 'FJL', gender: 'f', name: 'Female Junior Lead', group: 'Youth Lead'});
      v.mjl = TH.Factory.createCategory({
        shortName: 'MJL', gender: 'm', name: 'Male Junior Lead', group: 'Youth Lead'});
      v.fol = TH.Factory.createCategory({
        shortName: 'FOL', gender: 'f', name: 'Female Open Lead', group: 'Open Lead'});
      v.sam = TH.Factory.createClimber({
        name: 'Sam Smith', dateOfBirth: '1996-04-16', number: 333});
      TH.loginAs(v.user);

      v.rpc = TH.mockRpc();
    });
Example #6
0
    test("more than 30", ()=>{
      let tt = TH.Factory.createTeamType({_id: 'tt1'});
      let team = TH.Factory.createTeam({_id: 'team1'});
      let cat = TH.Factory.createCategory({_id: 'cat'});
      let event = TH.Factory.createEvent({teamType_ids: [tt._id],
                                          heats: {cat: cat.heatFormat}});
      let competitors = TH.Factory.createList(31, 'createCompetitor', (index, options)=>{
        options.team_ids = ['team1'];
        options.category_ids = ['cat'];
      });

      TH.Factory.createList(31, 'createResult', (index, options)=>{
        options.competitor_id = competitors[index]._id;
        options.scores = [0.1, 100*index];
        options.category_id = 'cat';

      });

      assert.equals(sut.getTeamScores(event), {tt1: {team1: 818}});
    });