Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
t.test('not dismissed during undo period, successful migration', assert => {
testSaga(startAccountMigrationSaga, startAccountMigration())
.next()
.inspect(effect => {
assert.deepEqual(
effect,
race({
shouldContinue: delay(5000, true),
cancel: take('DISMISS_ACCOUNT_MIGRATION'),
}),
);
})
.next({shouldContinue: true, cancel: null})
.put(accountMigrationUndoPeriodExpired())
.next()
.select(getCurrentAccountMigration)
.next(migration)
.call(migrateAccount, firebaseCredential)
test('userDoneTyping', assert => {
testSaga(userDoneTypingSaga)
.next()
.put(userDoneTyping())
.next()
.isDone();
assert.end();
});
test('toggleLibrary', assert => {
const scenario = new Scenario();
const userId = 'abc123';
const currentProject = project();
const {projectKey} = currentProject;
testSaga(toggleLibrarySaga, toggleLibrary(scenario.projectKey, 'jquery'))
.next()
.select(getCurrentProject)
.next(currentProject)
.select()
.next(scenario.state)
.call(getCurrentUserId, scenario.state)
.next(userId)
.call(getProject, scenario.state, {projectKey})
.next(currentProject)
.call(saveProject, userId, currentProject)
.next()
.put(projectSuccessfullySaved())
.next()
.isDone();
assert.end();
});
t.test('draft', assert => {
const assignmentState = 'DRAFT';
const assignment = {};
testSaga(createAssignmentSaga, {
payload: {
selectedCourseId,
dueDate,
assignmentState,
},
})
.next()
.select(getCurrentProject)
.next(project.toJS())
.call(createProjectSnapshot, project.toJS())
.next(snapshotKey)
.all([
call(createSnapshotUrl, snapshotKey),
call(generateTextPreview, project.toJS()),
])
.next([url, title])
t.test('with successful import', assert => {
const saga = testSaga(importGistSaga, applicationLoaded({gistId}));
saga.next().call(loadGistFromId, gistId);
const gist = gistData({html: 'test'});
saga.next(gist).inspect(effect => {
assert.equals(effect.type, 'PUT', 'yielded effect is a PUT');
assert.equal(
effect.payload.action.type,
'GIST_IMPORTED',
'action is GIST_IMPORTED',
);
assert.ok(
effect.payload.action.payload.projectKey,
'assigns a project key',
);
assert.deepEqual(
test('changeCurrentProject()', assert => {
const scenario = new Scenario();
const userId = 'abc123';
const currentProject = project();
const {projectKey} = currentProject;
testSaga(changeCurrentProjectSaga)
.next()
.select(getCurrentProject)
.next(currentProject)
.select()
.next(scenario.state)
.call(getCurrentUserId, scenario.state)
.next(userId)
.call(getProject, scenario.state, {projectKey})
.next(currentProject)
.call(saveProject, userId, currentProject)
.next()
.put(projectSuccessfullySaved())
.next()
.isDone();
assert.end();
});
assert.doesNotThrow(() => {
testSaga(handleAuthError, e)
.next()
.put(notificationTriggered('auth-error'))
.next()
.call([bugsnagClient, 'notify'], e, {
metaData: {code: 'auth/bogus-error'},
})
.next()
.isDone();
});
function startCompilation() {
const project = projectFactory();
return testSaga(validatedSourceSaga)
.next()
.select(getErrors)
.next(errors.noErrors.toJS())
.select(getCurrentProject)
.next(project)
.call(compileProject, project, {isInlinePreview: true});
}
});
it("initially waits for incoming request objects", function () {
testSaga(metrics.queryMetricsSaga).next().take(metrics.REQUEST);
});
it("correctly handles STOP_AUTO_REFRESH action", function() {
const state = new ManagedQuerySagaState();
state.channel = channel();
testSaga(processQueryManagementAction, state)
.next()
.take(state.channel)
.next(stopAutoRefresh(testQueryCounter))
.isDone();
const expected = new ManagedQuerySagaState();
expected.channel = state.channel;
expected.autoRefreshCount = -1;
assert.equal(state.autoRefreshCount, -1);
assert.deepEqual(state, expected);
});
});