   Project = null
   Chrome = null
 
+  prj1 = [
+    {
+      url: "http://redmine.com"
+      urlIndex: 2
+      id: 0
+      text: "prj1_0"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com"
+      urlIndex: 2
+      id: 1
+      text: "prj1_1"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com"
+      urlIndex: 2
+      id: 2
+      text: "prj1_2"
+      show: SHOW.DEFAULT
+    }
+  ]
+
+  prj2 = [
+    {
+      url: "http://redmine.com2"
+      urlIndex: 3
+      id: 0
+      text: "prj2_0"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com2"
+      urlIndex: 3
+      id: 1
+      text: "prj2_1"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com2"
+      urlIndex: 3
+      id: 2
+      text: "prj2_2"
+      show: SHOW.DEFAULT
+    }
+  ]
+
+  prj3 = [
+    {
+      url: "http://redmine.com3"
+      urlIndex: 4
+      id: 0
+      text: "prj3_0"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com3"
+      urlIndex: 4
+      id: 1
+      text: "prj3_1"
+      show: SHOW.DEFAULT
+    }, {
+      url: "http://redmine.com3"
+      urlIndex: 4
+      id: 2
+      text: "prj3_2"
+      show: SHOW.DEFAULT
+    }
+  ]
 
   beforeEach () ->
     angular.mock.module('timeTracker')


    it 'add 1 project', () ->
      expect(Project.get()).to.be.empty
      prj =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: ""
        show: SHOW.DEFAULT
      Project.add(prj)
      added = Project.get()
      expect(added[prj.url].index).to.be.equal(prj.urlIndex)
      expect(added[prj.url][prj.id].text).to.be.equal(prj.text)
      expect(added[prj.url][prj.id].show).to.be.equal(prj.show)

    it 'update a project', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2   # same url and urlIndex
        id: 0         # same id
        text: "second"
        show: SHOW.SHOW

      # execute
      Project.add(prj1)
      Project.add(prj2)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.not.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.not.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)

    it 'add 2 projects on same redmine server', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 1
        text: "second"
        show: SHOW.DEFAULT

      # execute
      Project.add(prj1)
      Project.add(prj2)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)

    it 'add 2 projects on different redmine server', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker2"
        urlIndex: 3 # url is different from prj1.
        id: 0
        text: "second"
        show: SHOW.DEFAULT

      # execute
      Project.add(prj1)
      Project.add(prj2)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)

    it 'add 3 projects on same redmine server', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 1
        text: "second"
        show: SHOW.DEFAULT
      prj3 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 2
        text: "third"
        show: SHOW.DEFAULT

      # execute
      Project.add(prj1)
      Project.add(prj2)
      Project.add(prj3)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)
      expect(added[prj3.url].index).to.be.equal(prj3.urlIndex)
      expect(added[prj3.url][prj3.id].text).to.be.equal(prj3.text)
      expect(added[prj3.url][prj3.id].show).to.be.equal(prj3.show)

    it 'add 3 projects on same/different redmine server', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker1"
        urlIndex: 3
        id: 1
        text: "second"
        show: SHOW.DEFAULT
      prj3 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 1
        text: "third"
        show: SHOW.DEFAULT

      # execute
      Project.add(prj1)
      Project.add(prj2)
      Project.add(prj3)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)
      expect(added[prj3.url].index).to.be.equal(prj3.urlIndex)
      expect(added[prj3.url][prj3.id].text).to.be.equal(prj3.text)
      expect(added[prj3.url][prj3.id].show).to.be.equal(prj3.show)

    it 'add 3 projects on different redmine server', () ->
      expect(Project.get()).to.be.empty

      # create test data
      prj1 =
        url: "https://github.com/ujiro99/RedmineTimeTracker"
        urlIndex: 2
        id: 0
        text: "first"
        show: SHOW.DEFAULT
      prj2 =
        url: "https://github.com/ujiro99/RedmineTimeTracker1"
        urlIndex: 3
        id: 0
        text: "second"
        show: SHOW.DEFAULT
      prj3 =
        url: "https://github.com/ujiro99/RedmineTimeTracker2"
        urlIndex: 4
        id: 0
        text: "third"
        show: SHOW.DEFAULT

      # execute
      Project.add(prj1)
      Project.add(prj2)
      Project.add(prj3)

      # assert
      added = Project.get()
      expect(added[prj1.url].index).to.be.equal(prj1.urlIndex)
      expect(added[prj1.url][prj1.id].text).to.be.equal(prj1.text)
      expect(added[prj1.url][prj1.id].show).to.be.equal(prj1.show)
      expect(added[prj2.url].index).to.be.equal(prj2.urlIndex)
      expect(added[prj2.url][prj2.id].text).to.be.equal(prj2.text)
      expect(added[prj2.url][prj2.id].show).to.be.equal(prj2.show)
      expect(added[prj3.url].index).to.be.equal(prj3.urlIndex)
      expect(added[prj3.url][prj3.id].text).to.be.equal(prj3.text)
      expect(added[prj3.url][prj3.id].show).to.be.equal(prj3.show)


  ###


    it 'should be empty, when remove 1 project from 1 project', () ->
      expect(Project.get()).to.be.empty
      
      # execute
      Project.add(prj1[0])
      Project.remove(prj1[0].url, prj1[0].id)

      # assert
      added = Project.get()
