debian-mirror-gitlab/spec/frontend/ide/stores/mutations/branch_spec.js

76 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import mutations from '~/ide/stores/mutations/branch';
import state from '~/ide/stores/state';
describe('Multi-file store branch mutations', () => {
let localState;
beforeEach(() => {
localState = state();
});
describe('SET_CURRENT_BRANCH', () => {
it('sets currentBranch', () => {
2021-09-04 01:27:46 +05:30
mutations.SET_CURRENT_BRANCH(localState, 'main');
2018-05-09 12:01:36 +05:30
2021-09-04 01:27:46 +05:30
expect(localState.currentBranchId).toBe('main');
2018-05-09 12:01:36 +05:30
});
});
2018-10-15 14:42:47 +05:30
describe('SET_BRANCH_COMMIT', () => {
it('sets the last commit on current project', () => {
localState.projects = {
Example: {
branches: {
2021-09-04 01:27:46 +05:30
main: {},
2018-10-15 14:42:47 +05:30
},
},
};
mutations.SET_BRANCH_COMMIT(localState, {
projectId: 'Example',
2021-09-04 01:27:46 +05:30
branchId: 'main',
2018-10-15 14:42:47 +05:30
commit: {
title: 'Example commit',
},
});
2021-09-04 01:27:46 +05:30
expect(localState.projects.Example.branches.main.commit.title).toBe('Example commit');
2018-10-15 14:42:47 +05:30
});
});
2019-09-04 21:01:54 +05:30
describe('SET_BRANCH_WORKING_REFERENCE', () => {
beforeEach(() => {
localState.projects = {
Foo: {
branches: {
bar: {},
},
},
};
});
it('sets workingReference for existing branch', () => {
mutations.SET_BRANCH_WORKING_REFERENCE(localState, {
projectId: 'Foo',
branchId: 'bar',
reference: 'foo-bar-ref',
});
expect(localState.projects.Foo.branches.bar.workingReference).toBe('foo-bar-ref');
});
it('does not fail on non-existent just yet branch', () => {
expect(localState.projects.Foo.branches.unknown).toBeUndefined();
mutations.SET_BRANCH_WORKING_REFERENCE(localState, {
projectId: 'Foo',
branchId: 'unknown',
reference: 'fun-fun-ref',
});
expect(localState.projects.Foo.branches.unknown).not.toBeUndefined();
expect(localState.projects.Foo.branches.unknown.workingReference).toBe('fun-fun-ref');
});
});
2018-05-09 12:01:36 +05:30
});