Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/CyberReboot/CRviz into Ph…
Browse files Browse the repository at this point in the history
…ase-2-Features
  • Loading branch information
rashley-iqt committed Feb 4, 2019
2 parents e6ce121 + 618a5f9 commit d73559c
Show file tree
Hide file tree
Showing 9 changed files with 667 additions and 620 deletions.
65 changes: 65 additions & 0 deletions src/epics/diff-dataset-epic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { expect } from 'chai';
import configureStore from "configure-store";

import {
setDataset,
selectMergedConfiguration,
selectDatasetDiff,
applyHashes
} from 'domain/dataset'
import { diffDataset } from "./diff-dataset-epic"

const uuidv4 = require('uuid/v4');

describe("diffDatasetEpic", () => {
let store;
const startOwner = uuidv4();
const startData = [
{ uid: "uid1", role: { role: "role", confidence: 80 } },
{ uid: "uid2", role: { role: "role", confidence: 80 } }
];
const endOwner = uuidv4();
const endData = [
{ uid: "uid3", role: { role: "role", confidence: 80 } },
{ uid: "uid2", role: { role: "other-role", confidence: 80 } }
];

beforeEach(() => {
store = configureStore();
const startAction$ = setDataset({ 'owner': startOwner, 'dataset': startData });
store.dispatch(startAction$);
const endAction$ = setDataset({ 'owner': endOwner, 'dataset': endData });
store.dispatch(endAction$);
});

afterEach(() => {
});

it("diff a dataset", (done) => {
const config = selectMergedConfiguration(store.getState());
const key = config.fields.filter(f => f.displayName === 'uid')
const ignore =[];
config.keyFields = key;
config.hashFields = config.fields;

const startDs = { 'owner': startOwner, 'dataset': startData };
applyHashes(startDs.dataset, config);

const endDs = { 'owner': endOwner, 'dataset':endData };
applyHashes(endDs.dataset, config);

const action$ = diffDataset({
'start': startDs,
'end': endDs,
'configuration': config,
'key': key, 'ignore':ignore
});
store.dispatch(action$);
const diffs = selectDatasetDiff(store.getState(), startOwner, endOwner);

expect(diffs.added.length).to.equal(1);
expect(diffs.removed.length).to.equal(1);
expect(diffs.changed.length).to.equal(1);
done();
});
});
Loading

0 comments on commit d73559c

Please sign in to comment.