Skip to content

Commit

Permalink
Added Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe committed Sep 13, 2017
1 parent 316e0d5 commit 102e5ca
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions LockTests/Presenters/DatabasePresenterSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ class DatabasePresenterSpec: QuickSpec {
expect(view.passwordManagerButton).to(beNil())
}

it("should have show password button") {
expect(view.showPasswordButton).toNot(beNil())
}

context("with password manager available") {

beforeEach {
Expand All @@ -237,6 +241,10 @@ class DatabasePresenterSpec: QuickSpec {
view = presenter.view as! DatabaseOnlyView
expect(view.passwordManagerButton).to(beNil())
}

it("should not have show password button") {
expect(view.showPasswordButton).to(beNil())
}
}

describe("user input") {
Expand Down Expand Up @@ -293,6 +301,12 @@ class DatabasePresenterSpec: QuickSpec {
expect(input.valid) == false
}

it("should toggle show password") {
expect(view.passwordField?.textField?.isSecureTextEntry).to(beTrue())
view.showPasswordButton?.onPress(view.showPasswordButton!)
expect(view.passwordField?.textField?.isSecureTextEntry).to(beFalse())
}

}

// MARK:- Log In
Expand Down Expand Up @@ -445,6 +459,10 @@ class DatabasePresenterSpec: QuickSpec {
expect(view.primaryButton?.title) == "SIGN UP"
}

it("should have show password button") {
expect(view.showPasswordButton).toNot(beNil())
}

describe("user input") {

it("should clear global message") {
Expand Down Expand Up @@ -504,6 +522,10 @@ class DatabasePresenterSpec: QuickSpec {
expect(view.passwordManagerButton).to(beNil())
}

it("should not show password manager when disabled") {
expect(view.passwordManagerButton).to(beNil())
}

context("with password manager available") {

beforeEach {
Expand All @@ -517,23 +539,17 @@ class DatabasePresenterSpec: QuickSpec {
expect(view.passwordManagerButton).toNot(beNil())
}

context("disable password manager") {

beforeEach {
presenter.passwordManager = passwordManager
presenter.passwordManager.enabled = false
view = presenter.view as! DatabaseOnlyView
view.switcher?.selected = .signup
view.switcher?.onSelectionChange(view.switcher!)
}

it("should not show password manager when disabled") {
expect(view.passwordManagerButton).to(beNil())
}

it("should not have show password button") {
expect(view.showPasswordButton).to(beNil())
}
}

it("should toggle show password") {
expect(view.passwordField?.textField?.isSecureTextEntry).to(beTrue())
view.showPasswordButton?.onPress(view.showPasswordButton!)
expect(view.passwordField?.textField?.isSecureTextEntry).to(beFalse())
}

}

describe("sign up action") {
Expand Down

0 comments on commit 102e5ca

Please sign in to comment.