This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/CyberReboot/CRviz into Ph…
…ase-2-Features
- Loading branch information
Showing
9 changed files
with
667 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
Oops, something went wrong.