mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Convert existing frontend tests to run in karma
This commit is contained in:
parent
3faa0556e8
commit
c7957b8ad4
2 changed files with 189 additions and 210 deletions
|
@ -1,23 +1,11 @@
|
|||
Path = require 'path'
|
||||
SandboxedModule = require "sandboxed-module"
|
||||
modulePath = Path.join __dirname, '../../../../../public/js/ide/history/HistoryV2Manager'
|
||||
sinon = require("sinon")
|
||||
expect = require("chai").expect
|
||||
|
||||
define ['ide/history/HistoryV2Manager'], (HistoryV2Manager) ->
|
||||
describe "HistoryV2Manager", ->
|
||||
beforeEach ->
|
||||
@moment = {}
|
||||
@ColorManager = {}
|
||||
SandboxedModule.require modulePath, globals:
|
||||
"define": (dependencies, builder) =>
|
||||
@HistoryV2Manager = builder(@moment, @ColorManager)
|
||||
|
||||
@scope =
|
||||
$watch: sinon.stub()
|
||||
$on: sinon.stub()
|
||||
@ide = {}
|
||||
|
||||
@historyManager = new @HistoryV2Manager(@ide, @scope)
|
||||
@historyManager = new HistoryV2Manager(@ide, @scope)
|
||||
|
||||
it "should setup the history scope on intialization", ->
|
||||
expect(@scope.history).to.deep.equal({
|
||||
|
|
|
@ -1,26 +1,17 @@
|
|||
Path = require 'path'
|
||||
SandboxedModule = require "sandboxed-module"
|
||||
modulePath = Path.join __dirname, '../../../../../public/js/ide/history/util/displayNameForUser'
|
||||
sinon = require("sinon")
|
||||
expect = require("chai").expect
|
||||
|
||||
define ['ide/history/util/displayNameForUser'], (displayNameForUser) ->
|
||||
describe "displayNameForUser", ->
|
||||
beforeEach ->
|
||||
SandboxedModule.require modulePath, globals:
|
||||
"define": (dependencies, builder) =>
|
||||
@displayNameForUser = builder()
|
||||
"window": @window = {}
|
||||
@window.user = { id: 42 }
|
||||
window.user = { id: 42 }
|
||||
|
||||
it "should return 'Anonymous' with no user", ->
|
||||
expect(
|
||||
@displayNameForUser(null)
|
||||
displayNameForUser(null)
|
||||
).to.equal "Anonymous"
|
||||
|
||||
it "should return 'you' when the user has the same id as the window", ->
|
||||
expect(
|
||||
@displayNameForUser({
|
||||
id: @window.user.id
|
||||
displayNameForUser({
|
||||
id: window.user.id
|
||||
email: "james.allen@overleaf.com"
|
||||
first_name: "James"
|
||||
last_name: "Allen"
|
||||
|
@ -29,8 +20,8 @@ describe "displayNameForUser", ->
|
|||
|
||||
it "should return the first_name and last_name when present", ->
|
||||
expect(
|
||||
@displayNameForUser({
|
||||
id: @window.user.id + 1
|
||||
displayNameForUser({
|
||||
id: window.user.id + 1
|
||||
email: "james.allen@overleaf.com"
|
||||
first_name: "James"
|
||||
last_name: "Allen"
|
||||
|
@ -39,8 +30,8 @@ describe "displayNameForUser", ->
|
|||
|
||||
it "should return only the firstAname if no last_name", ->
|
||||
expect(
|
||||
@displayNameForUser({
|
||||
id: @window.user.id + 1
|
||||
displayNameForUser({
|
||||
id: window.user.id + 1
|
||||
email: "james.allen@overleaf.com"
|
||||
first_name: "James"
|
||||
last_name: ""
|
||||
|
@ -49,8 +40,8 @@ describe "displayNameForUser", ->
|
|||
|
||||
it "should return the email username if there are no names", ->
|
||||
expect(
|
||||
@displayNameForUser({
|
||||
id: @window.user.id + 1
|
||||
displayNameForUser({
|
||||
id: window.user.id + 1
|
||||
email: "james.allen@overleaf.com"
|
||||
first_name: ""
|
||||
last_name: ""
|
||||
|
@ -59,8 +50,8 @@ describe "displayNameForUser", ->
|
|||
|
||||
it "should return the '?' if it has nothing", ->
|
||||
expect(
|
||||
@displayNameForUser({
|
||||
id: @window.user.id + 1
|
||||
displayNameForUser({
|
||||
id: window.user.id + 1
|
||||
email: ""
|
||||
first_name: ""
|
||||
last_name: ""
|
||||
|
|
Loading…
Reference in a new issue