How to use the mout/src/lang/deepClone function in mout

To help you get started, we’ve selected a few mout examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kitware / HPCCloud / test / redux / projects.js View on Github external
it('should update simulation step, delete the old taskflow', (done) => {
      const newStatus = 'complete';
      const newTaskflowId = 'some_id';
      const expectedSim = deepClone(simulationData[0]);
      expectedSim.steps.Simulation.status = newStatus;
      expectedSim.steps.Simulation.metadata.taskflowId = newTaskflowId;

      const expectedActions = [
        {
          type: 'DELETE_TASKFLOW',
          id: simulationData[0].steps.Simulation.metadata.taskflowId,
        },
        { type: Actions.UPDATE_SIMULATION, simulation: expectedSim },
      ];

      // we need to manually add the simulation to the state.
      store.getState().simulations.mapById[simulationData[0]._id] =
        simulationData[0];

      setSpy(client, 'updateSimulationStep', expectedSim);
github Kitware / HPCCloud / src / workflows / openfoam / tutorials / components / steps / Simulation / View.js View on Github external
function onVisualize(props) {
  const location = {
    pathname: `View/Simulation/${props.simulation._id}/Visualization`,
    query: Object.assign({}, props.location.query, { view: 'default' }),
    state: props.location.state,
  };
  const newSimState = deepClone(props.simulation);
  newSimState.steps.Visualization.metadata.dataDir =
    props.taskflow.flow.meta.dataDir;
  // newSimState.steps.Visualization.metadata.fileName = 'simulation/dataset.foam';
  newSimState.active = 'Visualization';
  newSimState.disabled = newSimState.disabled.filter(
    (step) => step !== 'Visualization'
  );

  dispatch(SimActions.saveSimulation(newSimState, null, location));
}
github Kitware / HPCCloud / test / redux / clusters.js View on Github external
it('should add an existing cluster', (done) => {
      const expectedAction = { type: Actions.ADD_EXISTING_CLUSTER, cluster };
      expect(Actions.addExistingCluster(cluster)).toDispatchActions(
        expectedAction,
        complete(done)
      );

      const newState = deepClone(initialState);
      newState.mapById[cluster._id] = cluster;
      newState.list = [cluster];
      expect(clustersReducer(initialState, expectedAction)).toEqual(newState);
    });
github Kitware / HPCCloud / test / redux / projects.js View on Github external
it('revokes permissions for a simulation', (done) => {
      const expectedSimulation = deepClone(simulationData[0]);
      setSpy(client, 'revokeSimulationAccess', expectedSimulation);
      expect(
        Actions.unShareSimulation(
          simulationData[0],
          [],
          [{ id: '123', level: 2 }]
        )
      ).toDispatchActions(
        { type: Actions.UPDATE_SIMULATION, simulation: expectedSimulation },
        done
      );
      expect(client.revokeSimulationAccess).toHaveBeenCalled();
    });
  });
github Kitware / HPCCloud / test / redux / taskflows.js View on Github external
it('should fetch a taskflow', (done) => {
      const clusters = [{ _id: 'a1' }, { _id: 'b2' }];
      const log = [{ entry: 'created...' }, { entry: 'running...' }];
      const flow = deepClone(taskflow.flow);
      flow.meta.jobs = [{ _id: 'job1', status: 'running' }];
      const expectedActions = [
        { type: Actions.ADD_TASKFLOW, taskflow: flow },
        {
          type: Actions.UPDATE_TASKFLOW_JOB_STATUS,
          taskflowId,
          jobId: 'job1',
          status: 'running',
        },
        { type: Actions.GET_TASKFLOW_JOB_LOG, taskflowId, jobId: 'job1', log },
      ];
      setSpy(client, 'getTaskflow', flow);
      setSpy(client, 'getJobLog', { log });
      setSpy(client, 'getJobStatus', { status: 'running' });
      setSpy(client, 'listClusters', clusters);
      expect(Actions.fetchTaskflow(taskflowId)).toDispatchActions(
github Kitware / HPCCloud / test / redux / volumes.js View on Github external
it('updates volume list', (done) => {
      const volumes = [
        { _id: 'a', name: 'vol_a' },
        { _id: 'b', name: 'vol_b' },
      ];
      const expectedAction = { type: Actions.UPDATE_VOLUMES, volumes };
      expect(Actions.updateVolumes(volumes)).toDispatchActions(
        expectedAction,
        complete(done)
      );

      const expectedState = deepClone(initialState);
      expectedState.list = volumes;
      expectedState.mapById = {
        a: Object.assign({}, volumeTemplate, { _id: 'a', name: 'vol_a' }),
        b: Object.assign({}, volumeTemplate, { _id: 'b', name: 'vol_b' }),
      };
      expect(volumeReducer(initialState, expectedAction)).toEqual(
        expectedState
      );
    });
github Kitware / HPCCloud / test / redux / clusters.js View on Github external
it("should update a cluster's status", () => {
      const newStatus = 'terminated';
      const myCluster = deepClone(cluster);
      const givenState = deepClone(initialState);
      givenState.mapById[myCluster._id] = myCluster;
      givenState.list.push(myCluster);

      const expectedState = deepClone(givenState);
      expectedState.mapById[myCluster._id].status = newStatus;
      expectedState.mapById[myCluster._id].classPrefix =
        style.statusTerminatedIcon;
      expectedState.list[0].status = newStatus;
      expectedState.list[0].classPrefix = style.statusTerminatedIcon;

      const action = {
        type: Actions.UPDATE_CLUSTER_STATUS,
        id: cluster._id,
        status: newStatus,
      };
      expect(clustersReducer(givenState, action)).toEqual(expectedState);
    });
  });
github Kitware / HPCCloud / test / redux / aws.js View on Github external
it('should add aws profile', (done) => {
      const expectedAction = { type: Actions.ADD_AWS_PROFILE };
      expect(Actions.addAWSProfile()).toDispatchActions(
        expectedAction,
        complete(done)
      );

      const expectedState = deepClone(awsState);
      expectedState.list.push(deepClone(awsTemplate));
      expectedState.active = 1;
      expect(awsReducer(awsState, expectedAction)).toEqual(expectedState);
    });
github Kitware / HPCCloud / test / redux / volumes.js View on Github external
it('fetches volume log and appends', (done) => {
      const logEntry = { entry: 'job running' };
      setSpy(client, 'getVolumeLog', { log: logEntry });
      const expectedAction = {
        type: Actions.APPEND_TO_VOLUME_LOG,
        id: 'abc',
        logEntry,
      };
      expect(Actions.getVolumeLog('abc', 3)).toDispatchActions(
        expectedAction,
        complete(done)
      );

      const givenState = deepClone(initialState);
      givenState.logById.abc = [{ entry: 'job starting' }];
      const expectedState = deepClone(givenState);
      expectedState.logById.abc.push(logEntry);
      expect(volumeReducer(givenState, expectedAction)).toEqual(expectedState);
    });
  });
github Kitware / HPCCloud / test / redux / network.js View on Github external
it('invalidates all network errors given *', (done) => {
      const expectedAction = { type: Actions.INVALIDATE_ERRORS, ids: '*' };
      expect(Actions.invalidateErrors('*')).toDispatchActions(
        expectedAction,
        complete(done)
      );

      const someTimeout = setTimeout(() => {}, 50);
      const givenState = deepClone(initialState);
      givenState.errorTimeout = someTimeout;
      givenState.error = {
        '01': { id: '01', resp: { data: { message: 'wow' } }, invalid: false },
        '02': { id: '02', resp: { data: { message: 'yay' } }, invalid: false },
      };
      givenState.activeErrors.form = ['01', '02'];
      givenState.activeErrors.application = ['03', '04'];
      const expectedState = deepClone(givenState);
      expectedState.errorTimeout = null;
      expectedState.error = {
        '01': Object.assign({}, givenState.error['01'], { invalid: true }),
        '02': Object.assign({}, givenState.error['02'], { invalid: true }),
      };
      expectedState.activeErrors.form = [];
      expectedState.activeErrors.application = [];