mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 06:04:02 +00:00
24 lines
680 B
CoffeeScript
24 lines
680 B
CoffeeScript
define [
|
|
"libs/chai"
|
|
"models/User"
|
|
"libs/sinon"
|
|
], (chai, User) ->
|
|
describe "User", ->
|
|
describe "findOrBuild", ->
|
|
describe "with an existing model", ->
|
|
beforeEach ->
|
|
@user = User.build "user-1"
|
|
@user.set("email", "test@example.com")
|
|
|
|
it "should return the same model", ->
|
|
@newUser = User.findOrBuild "user-1", email: "new@example.com"
|
|
@newUser.should.equal @user
|
|
@newUser.get("email").should.equal "new@example.com"
|
|
|
|
describe "without an existing model", ->
|
|
it "should return new a model with the correct id", ->
|
|
user = User.findOrBuild("user-2")
|
|
user.id.should.equal "user-2"
|
|
|
|
afterEach ->
|
|
User.loadedModels = {}
|