branch_spec.js 953 Bytes
Newer Older
1 2
import mutations from '~/ide/stores/mutations/branch';
import state from '~/ide/stores/state';
Phil Hughes's avatar
Phil Hughes committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

describe('Multi-file store branch mutations', () => {
  let localState;

  beforeEach(() => {
    localState = state();
  });

  describe('SET_CURRENT_BRANCH', () => {
    it('sets currentBranch', () => {
      mutations.SET_CURRENT_BRANCH(localState, 'master');

      expect(localState.currentBranchId).toBe('master');
    });
  });
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

  describe('SET_BRANCH_COMMIT', () => {
    it('sets the last commit on current project', () => {
      localState.projects = {
        Example: {
          branches: {
            master: {},
          },
        },
      };

      mutations.SET_BRANCH_COMMIT(localState, {
        projectId: 'Example',
        branchId: 'master',
        commit: {
          title: 'Example commit',
        },
      });

      expect(localState.projects.Example.branches.master.commit.title).toBe('Example commit');
    });
  });
Phil Hughes's avatar
Phil Hughes committed
40
});