{"size": 1353, "ext": "js", "max_stars_repo_path": "test/unit/specs/components/loginForm.spec.js", "max_stars_repo_name": "sdellis/lux-upgrade", "max_stars_repo_stars_event_min_datetime": "2018-05-02T20:53:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-30T19:10:24.000Z", "max_issues_repo_path": "test/unit/specs/components/loginForm.spec.js", "max_issues_repo_name": "sdellis/lux-upgrade", "max_issues_repo_issues_event_min_datetime": "2018-05-01T21:10:42.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-07T17:11:57.000Z", "max_forks_repo_path": "test/unit/specs/components/loginForm.spec.js", "max_forks_repo_name": "sdellis/lux-upgrade", "max_forks_repo_forks_event_min_datetime": "2018-07-27T23:11:33.000Z", "max_forks_repo_forks_event_max_datetime": "2018-07-27T23:11:33.000Z"}
{"max_stars_count": 7, "max_issues_count": 223, "max_forks_count": 1, "avg_line_length": 33.825, "max_line_length": 78, "alphanum_fraction": 0.6585365854}
import { createLocalVue, mount } from "@vue/test-utils"
import LoginForm from "@/patterns/LoginForm.vue"

// create an extended `Vue` constructor
const localVue = createLocalVue()

let wrapper

describe("LoginForm.vue", () => {
  beforeEach(() => {
    wrapper = mount(LoginForm, {
      localVue,
      stubs: ["input-text", "input-button", "alert"],
    })
  })

  it("should validate both email and password fields", () => {
    wrapper.vm.validate({ id: "email", value: "foo" })
    expect(wrapper.vm.errormessageEmail).toBe("You need to supply an email.")
    wrapper.vm.validate({ id: "email", value: "foo@bar.com" })
    expect(wrapper.vm.errormessageEmail).toBe("")
    wrapper.vm.validate({ id: "pwd", value: "" })
    expect(wrapper.vm.errormessagePwd).toBe("You need to supply a password.")
    wrapper.vm.validate({ id: "pwd", value: "foo" })
    expect(wrapper.vm.errormessagePwd).toBe("")
  })

  it("should show an alert component when showAlert is called", () => {
    expect(wrapper.vm.alert).toBe(false)
    wrapper.vm.showAlert({ alertMessage: "Success!", alertStatus: "success" })
    expect(wrapper.vm.alertMessage).toBe("Success!")
    expect(wrapper.vm.alertStatus).toBe("success")
    expect(wrapper.vm.alert).toBe(true)
  })

  it("has the expected html structure", () => {
    expect(wrapper.element).toMatchSnapshot()
  })
})
