Sha256: f69d7e1d55e470df969d070c2d27cedb35dc6ff2bb157ce6e939363f80f003fc

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

describe "alerts", ->
  beforeEach module("mb.controllers")

  $scope = null
  alerts = null

  beforeEach inject ($injector, $rootScope, $controller) ->
    $scope = $rootScope.$new()

    alerts = $injector.get("alerts")

    $controller "alerts",
      $scope: $scope,
      alerts: alerts

  it "assings flash messages", ->
    expect($scope.alertMessages).toBeDefined()
    expect($scope.alertMessages).toEqual([])

    alerts.info("Test message.")
    expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Test message.")

  describe "#disposeAlert", ->
    it "disposes an alert at the given index", ->
      # Given
      alerts.info("Information..")
      alerts.error("Error..")
      spyOn(alerts, "dispose").andCallThrough()

      # When
      $scope.disposeAlert(2)

      # Then
      expect(alerts.dispose).toHaveBeenCalledWith(2)
      expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Information..")
      expect($scope.alertMessages).not.toContain(id: 2, type: "error", text: "Error..")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_browser-0.2.0.rc2 spec/javascripts/app/controllers/alerts_spec.js.coffee