mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-24 03:01:18 +00:00
Speed up unit tests by only generating big fixtures once up front
This commit is contained in:
parent
dfe26262ec
commit
8dda44f880
1 changed files with 13 additions and 12 deletions
|
@ -5,14 +5,15 @@ expect = chai.expect
|
|||
modulePath = "../../../../app/js/UpdateCompressor.js"
|
||||
SandboxedModule = require('sandboxed-module')
|
||||
|
||||
bigstring = ("a" for [0 .. 2*1024*1024]).join("")
|
||||
mediumstring = ("a" for [0 .. 1024*1024]).join("")
|
||||
|
||||
describe "UpdateCompressor", ->
|
||||
beforeEach ->
|
||||
@UpdateCompressor = SandboxedModule.require modulePath, requires:
|
||||
"../lib/diff_match_patch": require("../../../../app/lib/diff_match_patch")
|
||||
@user_id = "user-id-1"
|
||||
@other_user_id = "user-id-2"
|
||||
@bigstring = ("a" for [0 .. 2*1024*1024]).join("")
|
||||
@mediumstring = ("a" for [0 .. 1024*1024]).join("")
|
||||
@ts1 = Date.now()
|
||||
@ts2 = Date.now() + 1000
|
||||
|
||||
|
@ -150,7 +151,7 @@ describe "UpdateCompressor", ->
|
|||
meta: ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 6, i: @bigstring }
|
||||
op: { p: 6, i: bigstring }
|
||||
meta: ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}])
|
||||
|
@ -159,47 +160,47 @@ describe "UpdateCompressor", ->
|
|||
meta: start_ts: @ts1, end_ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 6, i: @bigstring }
|
||||
op: { p: 6, i: bigstring }
|
||||
meta: start_ts: @ts2, end_ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}]
|
||||
|
||||
it "should not append inserts that are too big (first op)", ->
|
||||
expect(@UpdateCompressor.compressUpdates [{
|
||||
op: { p: 3, i: @bigstring }
|
||||
op: { p: 3, i: bigstring }
|
||||
meta: ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 3 + @bigstring.length, i: "bar" }
|
||||
op: { p: 3 + bigstring.length, i: "bar" }
|
||||
meta: ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}])
|
||||
.to.deep.equal [{
|
||||
op: { p: 3, i: @bigstring }
|
||||
op: { p: 3, i: bigstring }
|
||||
meta: start_ts: @ts1, end_ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 3 + @bigstring.length, i: "bar" }
|
||||
op: { p: 3 + bigstring.length, i: "bar" }
|
||||
meta: start_ts: @ts2, end_ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}]
|
||||
|
||||
it "should not append inserts that are too big (first and second op)", ->
|
||||
expect(@UpdateCompressor.compressUpdates [{
|
||||
op: { p: 3, i: @mediumstring }
|
||||
op: { p: 3, i: mediumstring }
|
||||
meta: ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 3 + @mediumstring.length, i: @mediumstring }
|
||||
op: { p: 3 + mediumstring.length, i: mediumstring }
|
||||
meta: ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}])
|
||||
.to.deep.equal [{
|
||||
op: { p: 3, i: @mediumstring }
|
||||
op: { p: 3, i: mediumstring }
|
||||
meta: start_ts: @ts1, end_ts: @ts1, user_id: @user_id
|
||||
v: 42
|
||||
}, {
|
||||
op: { p: 3 + @mediumstring.length, i: @mediumstring }
|
||||
op: { p: 3 + mediumstring.length, i: mediumstring }
|
||||
meta: start_ts: @ts2, end_ts: @ts2, user_id: @user_id
|
||||
v: 43
|
||||
}]
|
||||
|
|
Loading…
Reference in a new issue