Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Test operation identification functions
Browse files Browse the repository at this point in the history
  • Loading branch information
maier49 committed Dec 14, 2016
1 parent c77f093 commit 176d5d5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/unit/patch/createOperation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as registerSuite from 'intern!object';
import * as assert from 'intern/chai!assert';
import createOperation, { OperationType } from '../../../src/patch/createOperation';
import createOperation, {
OperationType, isMove, isCopy, isReplace, isRemove,
isAdd, isTest
} from '../../../src/patch/createOperation';

registerSuite({
name: 'Operation',
Expand Down Expand Up @@ -142,5 +145,20 @@ registerSuite({

const operation = createOperation(OperationType.Copy, ['prop1'], null, ['prop2']);
assert.strictEqual(operation.toString(), '{"op":"copy","path":"prop1","from":"prop2"}');
},
'Should identify operation type'(this: any) {
const move = createOperation(OperationType.Move, ['prop2'], null, ['prop1']);
const copy = createOperation(OperationType.Copy, ['prop2'], null, ['prop1']);
const replace = createOperation(OperationType.Replace, ['prop1'], 2);
const remove = createOperation(OperationType.Remove, ['prop1']);
const add = createOperation(OperationType.Add, ['prop1'], 1);
const test = createOperation(OperationType.Test, ['prop1'], 2);

assert.isTrue(isMove(move), 'Didn\'t properly identify move operation');
assert.isTrue(isCopy(copy), 'Didn\'t properly identify copy operation');
assert.isTrue(isReplace(replace), 'Didn\'t properly identify replace operation');
assert.isTrue(isRemove(remove), 'Didn\'t properly identify remove operation');
assert.isTrue(isAdd(add), 'Didn\'t properly identify add operation');
assert.isTrue(isTest(test), 'Didn\'t properly identify test operation');
}
});

0 comments on commit 176d5d5

Please sign in to comment.