| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744 |
- 'use strict'
- const _ = require('lodash')
- const { expect } = require('chai')
- const ot = require('..')
- const File = ot.File
- const AddFileOperation = ot.AddFileOperation
- const MoveFileOperation = ot.MoveFileOperation
- const EditFileOperation = ot.EditFileOperation
- const NoOperation = ot.NoOperation
- const Operation = ot.Operation
- const TextOperation = ot.TextOperation
- const Snapshot = ot.Snapshot
- describe('Operation', function () {
- function makeEmptySnapshot() {
- return new Snapshot()
- }
- function makeOneFileSnapshot() {
- const snapshot = makeEmptySnapshot()
- snapshot.addFile('foo', File.fromString(''))
- return snapshot
- }
- function makeTwoFileSnapshot() {
- const snapshot = makeOneFileSnapshot()
- snapshot.addFile('bar', File.fromString('a'))
- return snapshot
- }
- function addFile(pathname, content) {
- return new AddFileOperation(pathname, File.fromString(content))
- }
- function roundTripOperation(operation) {
- return Operation.fromRaw(operation.toRaw())
- }
- function deepCopySnapshot(snapshot) {
- return Snapshot.fromRaw(snapshot.toRaw())
- }
- function runConcurrently(operation0, operation1, snapshot) {
- const operations = [
- // make sure they survive serialization
- roundTripOperation(operation0),
- roundTripOperation(operation1),
- ]
- const primeOperations = Operation.transform(operation0, operation1)
- const originalSnapshot = snapshot || makeEmptySnapshot()
- const snapshotA = deepCopySnapshot(originalSnapshot)
- const snapshotB = deepCopySnapshot(originalSnapshot)
- operations[0].applyTo(snapshotA)
- operations[1].applyTo(snapshotB)
- primeOperations[0].applyTo(snapshotB)
- primeOperations[1].applyTo(snapshotA)
- expect(snapshotA).to.eql(snapshotB)
- return {
- snapshot: snapshotA,
- operations,
- primeOperations,
- log() {
- console.log(this)
- return this
- },
- expectNoTransform() {
- expect(this.operations).to.eql(this.primeOperations)
- return this
- },
- swap() {
- return runConcurrently(operation1, operation0, originalSnapshot)
- },
- expectFiles(files) {
- this.expectedFiles = files
- expect(this.snapshot.countFiles()).to.equal(_.size(files))
- _.forOwn(files, (expectedFile, pathname) => {
- if (_.isString(expectedFile)) {
- expectedFile = { content: expectedFile, metadata: {} }
- }
- const file = this.snapshot.getFile(pathname)
- expect(file.getContent()).to.equal(expectedFile.content)
- expect(file.getMetadata()).to.eql(expectedFile.metadata)
- })
- return this
- },
- expectSymmetry() {
- if (!this.expectedFiles) {
- throw new Error('must call expectFiles before expectSymmetry')
- }
- this.swap().expectFiles(this.expectedFiles)
- return this
- },
- expectPrime(index, klass) {
- expect(this.primeOperations[index]).to.be.an.instanceof(klass)
- return this
- },
- tap(fn) {
- fn.call(this)
- return this
- },
- }
- }
- // shorthand for creating an edit operation
- function edit(pathname, textOperationOps) {
- return Operation.editFile(
- pathname,
- TextOperation.fromJSON({ textOperation: textOperationOps })
- )
- }
- it('transforms AddFile-AddFile with different names', function () {
- runConcurrently(addFile('foo', ''), addFile('bar', 'a'))
- .expectNoTransform()
- .expectFiles({ bar: 'a', foo: '' })
- .expectSymmetry()
- })
- it('transforms AddFile-AddFile with same name', function () {
- // the second file 'wins'
- runConcurrently(addFile('foo', ''), addFile('foo', 'a'))
- .expectFiles({ foo: 'a' })
- // if the first add was committed first, the second add overwrites it
- .expectPrime(1, AddFileOperation)
- // if the second add was committed first, the first add becomes a no-op
- .expectPrime(0, NoOperation)
- .swap()
- .expectFiles({ foo: '' })
- })
- it('transforms AddFile-MoveFile with no conflict', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- addFile('bar', 'a'),
- makeOneFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ bar: 'a', baz: '' })
- .expectSymmetry()
- })
- it('transforms AddFile-MoveFile with move from new file', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- addFile('foo', 'a'),
- makeOneFileSnapshot()
- )
- .expectFiles({ baz: 'a' })
- // if the move was committed first, the add overwrites it
- .expectPrime(1, AddFileOperation)
- // if the add was committed first, the move appears in the history
- .expectPrime(0, MoveFileOperation)
- .expectSymmetry()
- })
- it('transforms AddFile-MoveFile with move to new file', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- addFile('baz', 'a'),
- makeOneFileSnapshot()
- )
- .expectFiles({ baz: 'a' })
- // if the move was committed first, the add overwrites it
- .expectPrime(1, AddFileOperation)
- // if the add was committed first, the move becomes a delete
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- expect(this.primeOperations[0].isRemoveFile()).to.be.true
- })
- .expectSymmetry()
- })
- it('transforms AddFile-RemoveFile with no conflict', function () {
- runConcurrently(
- Operation.removeFile('foo'),
- addFile('bar', 'a'),
- makeOneFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ bar: 'a' })
- .expectSymmetry()
- })
- it('transforms AddFile-RemoveFile that removes added file', function () {
- runConcurrently(
- Operation.removeFile('foo'),
- addFile('foo', 'a'),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: 'a' })
- // if the move was committed first, the add overwrites it
- .expectPrime(1, AddFileOperation)
- // if the add was committed first, the move gets dropped
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms AddFile-EditFile with no conflict', function () {
- runConcurrently(
- edit('foo', ['x']),
- addFile('bar', 'a'),
- makeOneFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ bar: 'a', foo: 'x' })
- .expectSymmetry()
- })
- it('transforms AddFile-EditFile when new file is edited', function () {
- runConcurrently(
- edit('foo', ['x']),
- addFile('foo', 'a'),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: 'a' })
- // if the edit was committed first, the add overwrites it
- .expectPrime(1, AddFileOperation)
- // if the add was committed first, the edit gets dropped
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms AddFile-SetFileMetadata with no conflict', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- addFile('bar', 'a'),
- Operation.setFileMetadata('foo', testMetadata),
- makeOneFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ foo: { content: '', metadata: testMetadata }, bar: 'a' })
- .expectSymmetry()
- })
- it('transforms AddFile-SetFileMetadata with same name', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- addFile('foo', 'x'),
- Operation.setFileMetadata('foo', testMetadata),
- makeEmptySnapshot()
- )
- .expectFiles({ foo: { content: 'x', metadata: testMetadata } })
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile with no conflict', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- Operation.moveFile('bar', 'bat'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ bat: 'a', baz: '' })
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile same move foo->foo, foo->foo', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.moveFile('foo', 'foo'),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: '' })
- .expectPrime(1, NoOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile no-op foo->foo, foo->bar', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.moveFile('foo', 'bar'),
- makeOneFileSnapshot()
- )
- .expectFiles({ bar: '' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile no-op foo->foo, bar->foo', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.moveFile('foo', 'bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ bar: '' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile no-op foo->foo, bar->bar', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.moveFile('bar', 'bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ bar: 'a', foo: '' })
- .expectPrime(1, NoOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile same move foo->bar, foo->bar', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.moveFile('foo', 'bar'),
- makeOneFileSnapshot()
- )
- .expectFiles({ bar: '' })
- .expectPrime(1, NoOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile opposite foo->bar, bar->foo', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.moveFile('bar', 'foo'),
- makeTwoFileSnapshot()
- )
- .expectFiles([])
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- expect(this.primeOperations[1].isRemoveFile()).to.be.true
- expect(this.primeOperations[1].getPathname()).to.equal('bar')
- expect(this.primeOperations[0].isRemoveFile()).to.be.true
- expect(this.primeOperations[0].getPathname()).to.equal('foo')
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile no-op foo->foo, bar->baz', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.moveFile('bar', 'baz'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ baz: 'a', foo: '' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile diverge foo->bar, foo->baz', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.moveFile('foo', 'baz'),
- makeOneFileSnapshot()
- )
- .expectFiles({ baz: '' })
- // if foo->bar was committed first, the second move becomes bar->baz
- .expectPrime(1, MoveFileOperation)
- // if foo->baz was committed first, the second move becomes a no-op
- .expectPrime(0, NoOperation)
- .tap(function () {
- expect(this.primeOperations[1].getPathname()).to.equal('bar')
- expect(this.primeOperations[1].getNewPathname()).to.equal('baz')
- })
- .swap()
- .expectFiles({ bar: '' })
- })
- it('transforms MoveFile-MoveFile transitive foo->baz, bar->foo', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- Operation.moveFile('bar', 'foo'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ baz: 'a' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile transitive foo->bar, bar->baz', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.moveFile('bar', 'baz'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ baz: '' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-MoveFile converge foo->baz, bar->baz', function () {
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- Operation.moveFile('bar', 'baz'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ baz: 'a' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- // if foo->baz was committed first, we just apply the move
- expect(this.primeOperations[1]).to.eql(this.operations[1])
- // if bar->baz was committed first, the other move becomes a remove
- expect(this.primeOperations[0].isRemoveFile()).to.be.true
- expect(this.primeOperations[0].getPathname()).to.equal('foo')
- })
- .swap()
- .expectFiles({ baz: '' })
- })
- it('transforms MoveFile-RemoveFile no-op foo->foo, foo->', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.removeFile('foo'),
- makeOneFileSnapshot()
- )
- .expectFiles([])
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, NoOperation)
- .tap(function () {
- expect(this.primeOperations[1].isRemoveFile()).to.be.true
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-RemoveFile same move foo->, foo->', function () {
- runConcurrently(
- Operation.removeFile('foo'),
- Operation.removeFile('foo'),
- makeOneFileSnapshot()
- )
- .expectFiles([])
- .expectPrime(1, NoOperation)
- .expectPrime(0, NoOperation)
- .expectSymmetry()
- })
- it('transforms MoveFile-RemoveFile no conflict foo->, bar->', function () {
- runConcurrently(
- Operation.removeFile('foo'),
- Operation.removeFile('bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles([])
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms MoveFile-RemoveFile no conflict foo->foo, bar->', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.removeFile('bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ foo: '' })
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, NoOperation)
- .tap(function () {
- expect(this.primeOperations[1].isRemoveFile()).to.be.true
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-RemoveFile transitive foo->, bar->foo', function () {
- runConcurrently(
- Operation.removeFile('foo'),
- Operation.moveFile('bar', 'foo'),
- makeTwoFileSnapshot()
- )
- .expectFiles([])
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- expect(this.primeOperations[1].isRemoveFile()).to.be.true
- expect(this.primeOperations[1].getPathname()).to.equal('bar')
- expect(this.primeOperations[0].isRemoveFile()).to.be.true
- expect(this.primeOperations[0].getPathname()).to.equal('foo')
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-RemoveFile transitive foo->bar, bar->', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.removeFile('bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles({})
- .expectPrime(1, MoveFileOperation)
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- expect(this.primeOperations[1].isRemoveFile()).to.be.true
- expect(this.primeOperations[1].getPathname()).to.equal('bar')
- expect(this.primeOperations[0].isRemoveFile()).to.be.true
- expect(this.primeOperations[0].getPathname()).to.equal('foo')
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-EditFile with no conflict', function () {
- runConcurrently(
- Operation.moveFile('bar', 'baz'),
- edit('foo', ['x']),
- makeTwoFileSnapshot()
- )
- .expectFiles({ baz: 'a', foo: 'x' })
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms MoveFile-EditFile with edit on pathname', function () {
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- edit('foo', ['x']),
- makeOneFileSnapshot()
- )
- .expectFiles({ bar: 'x' })
- .expectPrime(1, EditFileOperation)
- .expectPrime(0, MoveFileOperation)
- .tap(function () {
- expect(this.primeOperations[1].getPathname()).to.equal('bar')
- expect(this.primeOperations[0].getPathname()).to.equal('foo')
- expect(this.primeOperations[0].getNewPathname()).to.equal('bar')
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-EditFile with edit on new pathname', function () {
- runConcurrently(
- Operation.moveFile('bar', 'foo'),
- edit('foo', ['x']),
- makeTwoFileSnapshot()
- )
- .expectFiles({ foo: 'a' })
- .expectPrime(1, NoOperation)
- .tap(function () {
- expect(this.primeOperations[0]).to.eql(this.operations[0])
- })
- .expectSymmetry()
- })
- it('transforms MoveFile-EditFile with no-op move', function () {
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- edit('foo', ['x']),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: 'x' })
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms MoveFile-SetFileMetadata with no conflict', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.moveFile('foo', 'baz'),
- Operation.setFileMetadata('bar', testMetadata),
- makeTwoFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ bar: { content: 'a', metadata: testMetadata }, baz: '' })
- .expectSymmetry()
- })
- it('transforms MoveFile-SetFileMetadata with set on pathname', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.setFileMetadata('foo', testMetadata),
- makeOneFileSnapshot()
- )
- .expectFiles({ bar: { content: '', metadata: testMetadata } })
- .expectSymmetry()
- })
- it('transforms MoveFile-SetFileMetadata w/ set on new pathname', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.moveFile('foo', 'bar'),
- Operation.setFileMetadata('bar', testMetadata),
- makeTwoFileSnapshot()
- )
- // move wins
- .expectFiles({ bar: { content: '', metadata: {} } })
- .expectSymmetry()
- })
- it('transforms MoveFile-SetFileMetadata with no-op move', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.moveFile('foo', 'foo'),
- Operation.setFileMetadata('foo', testMetadata),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: { content: '', metadata: testMetadata } })
- .expectSymmetry()
- })
- it('transforms EditFile-EditFile with no conflict', function () {
- runConcurrently(
- edit('foo', ['x']),
- edit('bar', [1, 'x']),
- makeTwoFileSnapshot()
- )
- .expectFiles({ bar: 'ax', foo: 'x' })
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms EditFile-EditFile on same file', function () {
- runConcurrently(
- edit('foo', ['x']),
- edit('foo', ['y']),
- makeOneFileSnapshot()
- )
- .expectFiles({ foo: 'xy' })
- .expectPrime(1, EditFileOperation)
- .expectPrime(0, EditFileOperation)
- .tap(function () {
- expect(this.primeOperations[1].getOperation().toJSON()).to.eql({
- textOperation: [1, 'y'],
- })
- expect(this.primeOperations[0].getOperation().toJSON()).to.eql({
- textOperation: ['x', 1],
- })
- })
- .swap()
- .expectFiles({ foo: 'yx' })
- })
- it('transforms EditFile-RemoveFile with no conflict', function () {
- runConcurrently(
- edit('foo', ['x']),
- Operation.removeFile('bar'),
- makeTwoFileSnapshot()
- )
- .expectFiles({ foo: 'x' })
- .expectNoTransform()
- .expectSymmetry()
- })
- it('transforms EditFile-RemoveFile on same file', function () {
- runConcurrently(
- edit('foo', ['x']),
- Operation.removeFile('foo'),
- makeOneFileSnapshot()
- )
- .expectFiles({})
- .expectSymmetry()
- })
- it('transforms EditFile-SetFileMetadata with no conflict', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- edit('foo', ['x']),
- Operation.setFileMetadata('bar', testMetadata),
- makeTwoFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({
- foo: { content: 'x', metadata: {} },
- bar: { content: 'a', metadata: testMetadata },
- })
- .expectSymmetry()
- })
- it('transforms EditFile-SetFileMetadata on same file', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- edit('foo', ['x']),
- Operation.setFileMetadata('foo', testMetadata),
- makeOneFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ foo: { content: 'x', metadata: testMetadata } })
- .expectSymmetry()
- })
- it('transforms SetFileMetadata-SetFileMetadata w/ no conflict', function () {
- runConcurrently(
- Operation.setFileMetadata('foo', { baz: 1 }),
- Operation.setFileMetadata('bar', { baz: 2 }),
- makeTwoFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({
- foo: { content: '', metadata: { baz: 1 } },
- bar: { content: 'a', metadata: { baz: 2 } },
- })
- .expectSymmetry()
- })
- it('transforms SetFileMetadata-SetFileMetadata on same file', function () {
- runConcurrently(
- Operation.setFileMetadata('foo', { baz: 1 }),
- Operation.setFileMetadata('foo', { baz: 2 }),
- makeOneFileSnapshot()
- )
- // second op wins
- .expectFiles({ foo: { content: '', metadata: { baz: 2 } } })
- .swap()
- // first op wins
- .expectFiles({ foo: { content: '', metadata: { baz: 1 } } })
- })
- it('transforms SetFileMetadata-RemoveFile with no conflict', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.setFileMetadata('foo', testMetadata),
- Operation.removeFile('bar'),
- makeTwoFileSnapshot()
- )
- .expectNoTransform()
- .expectFiles({ foo: { content: '', metadata: testMetadata } })
- .expectSymmetry()
- })
- it('transforms SetFileMetadata-RemoveFile on same file', function () {
- const testMetadata = { baz: 1 }
- runConcurrently(
- Operation.setFileMetadata('foo', testMetadata),
- Operation.removeFile('foo'),
- makeOneFileSnapshot()
- )
- .expectFiles({})
- .expectSymmetry()
- })
- })
|