Commit 98b1bda5 authored by Samantha Ming's avatar Samantha Ming

Convert branches-select component to jest

parent a01fb250
......@@ -8,7 +8,6 @@ const TEST_DEFAULT_BRANCH = { name: 'Any branch' };
const TEST_PROJECT_ID = '1';
const TEST_PROTECTED_BRANCHES = [{ id: 1, name: 'master' }, { id: 2, name: 'development' }];
const TEST_BRANCHES_SELECTIONS = [TEST_DEFAULT_BRANCH, ...TEST_PROTECTED_BRANCHES];
const DEBOUNCE_TIME = 250;
const waitForEvent = ($input, event) => new Promise(resolve => $input.one(event, resolve));
const select2Container = () => document.querySelector('.select2-container');
const select2DropdownOptions = () => document.querySelectorAll('.result-name');
......@@ -39,18 +38,18 @@ describe('Branches Select', () => {
const search = (term = '') => {
$input.select2('search', term);
jasmine.clock().tick(DEBOUNCE_TIME);
jest.runAllTimers();
};
beforeEach(() => {
jasmine.clock().install();
spyOn(Api, 'projectProtectedBranches').and.returnValue(
Promise.resolve(TEST_PROTECTED_BRANCHES),
);
jest.useFakeTimers();
jest
.spyOn(Api, 'projectProtectedBranches')
.mockReturnValue(Promise.resolve(TEST_PROTECTED_BRANCHES));
});
afterEach(() => {
jasmine.clock().uninstall();
jest.clearAllTimers();
wrapper.destroy();
});
......@@ -84,6 +83,7 @@ describe('Branches Select', () => {
it('fetches protected branches with search term', done => {
const term = 'lorem';
waitForEvent($input, 'select2-loaded')
.then(() => {})
.then(done)
.catch(done.fail);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment