<commit_before>package uk.ac.surrey.soc.cress.extrawidgets.plugin

import scala.Array.canBuildFrom

import org.nlogo.app.App
import org.nlogo.app.ToolsMenu
import org.scalatest.FunSuite
import org.scalatest.matchers.ShouldMatchers

import javax.swing.JMenuItem
import util.NetLogoInitializer.extraWidgetsPlugin

class TabsManagerTests extends FunSuite with ShouldMatchers {

  test("'" + GUIStrings.ToolsMenu.CreateTab + "' added to Tools menu") {
    for (ewp ← extraWidgetsPlugin) {
      val items = ewp.toolsMenu.getMenuComponents.collect {
        case item: JMenuItem if item.getText == GUIStrings.ToolsMenu.CreateTab ⇒
          item
      }
      items should have size 1
    }
  }

}<commit_msg>use FunSpec and add new tabs tests<commit_after>package uk.ac.surrey.soc.cress.extrawidgets.plugin

import scala.Array.canBuildFrom

import org.scalatest.FunSpec
import org.scalatest.GivenWhenThen
import org.scalatest.matchers.ShouldMatchers

import GUIStrings.TabsManager.TabNameMustBeNonEmpty
import GUIStrings.TabsManager.TabNameMustBeUnique
import akka.dispatch.Await
import akka.util.duration.intToDurationInt
import javax.swing.JMenuItem
import util.NetLogoInitializer.extraWidgetsPlugin

class TabsManagerTests extends FunSpec with ShouldMatchers with GivenWhenThen {

  describe("The TabsManager") {

    val ewp = Await.result(extraWidgetsPlugin, 30 seconds)
    val tm = ewp.tabsManager

    it("should add '" + GUIStrings.ToolsMenu.CreateTab + "' to Tools menu") {
      for (ewp ← extraWidgetsPlugin) {
        val items = ewp.toolsMenu.getMenuComponents.collect {
          case item: JMenuItem if item.getText == GUIStrings.ToolsMenu.CreateTab ⇒
            item
        }
        items should have size 1
      }
    }

    it("should be able to create extra widgets tabs") {
      tm.addTab("first tab") should be('right)
    }

    it("should not able to create tabs with duplicate names") {
      tm.addTab("first tab") shouldEqual Left(TabNameMustBeUnique)
    }

    it("should not be able to create tabs with empty names") {
      tm.addTab("") shouldEqual Left(TabNameMustBeNonEmpty)
    }

    it("should be able to create a second tab with a different name") {
      tm.addTab("second tab") should be('right)
    }
  }

}
{'fraction_non_alphanumeric': 0.0853712761227212, 'fraction_numerical': 0.0017785682525566918, 'mean_word_length': 3.6391752577319587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4049053', 'n_tokens_mistral': 714, 'n_tokens_neox': 680, 'n_words': 174}